validator<T> method

FormFieldValidator<T> validator<T>(
  1. Form4FieldState<T> field
)

Implementation

FormFieldValidator<T> validator<T>(Form4FieldState<T> field)
{
  return (v) {
    String? res;
    if (field.widget.validator != null) {
      res = field.widget.validator!(field.currentValue);
      if (res != null && res.isNotEmpty) {
        return res;
      }
    }

    return fieldErrors.containsKey(field.widget.name)
        ? fieldErrors[field.widget.name]!
        : null;
  };
}