themisir / form-validator

Simplest form validation for flutter form widgets
https://pub.dev/packages/form_validator
MIT License
78 stars 41 forks source link

Always required #30

Open Paroca72 opened 2 years ago

Paroca72 commented 2 years ago

It seems the field is always required

final ValidationBuilder validationBuilder = ValidationBuilder().email('Wrong Email Format');
String? _errorText = validationBuilder.build()(null);

Result "The field is required"

final ValidationBuilder validationBuilder = ValidationBuilder().email('Wrong Email Format');
String? _errorText = validationBuilder.build()('');

Result "Wrong Email Format"

themisir commented 2 years ago

You can set optional parameter when constructing ValidationBuilder to set value as optional (not-required). In that case if null or empty string value is provided the validation will be passed.