Open morrowyn opened 3 years ago
Yeah, it appears that when using a TextEditingController, the value is often silently converted from a null into an empty string, so as a result this required check never hits, even though the fields are empty.
Workaround is adding minLength(1)
but this is a bit silly and also gives a not very helpful error message.
Another workaround is an extension method:
extension CustomValidationBuilder on ValidationBuilder {
notEmpty() => add((value) {
return value.isEmpty ? 'This field is required' : null;
});
}
ValidationBuilder().required("").build() only works on strings that are null. However when a string is empty "" the validator says that it's valid. I expected an invalid error.