import 'package:flutter/material.dart';

import 'package:fancy_password_field/fancy_password_field.dart';

import 'package:pweb/widgets/password/hint/error.dart';
import 'package:pweb/widgets/password/hint/widget.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


Widget shortValidation(BuildContext context, Set<ValidationRule> rules, String value) {
  if (value.isEmpty) return Container();
  final failedRules = rules.where((rule) => !rule.validate(value));
  return (failedRules.isNotEmpty) 
    ? PasswordValidationOutput(
        children: [
          PasswordValidationErrorLabel(
            labelText: AppLocalizations.of(context)!.passwordValidationError(
              rules.firstWhere((rule) => !rule.validate(value)).name
            ),
          ),
        ], 
      )
    : Container();
} 