Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added notBlank validator #9

Closed
wants to merge 1 commit into from
Closed

added notBlank validator #9

wants to merge 1 commit into from

Conversation

masseelch
Copy link
Contributor

I myself needed it and i think many other will do too.

Tests are added.

@themisir
Copy link
Owner

I have changed .required logic yesterday which now checks if length > 0. It's now available as prerelease that you can get v0.1.6-next version here.

@masseelch
Copy link
Contributor Author

Ha. How unfortunate 😄

I still think, you should split required into notNull and notBlank.

@masseelch masseelch closed this Aug 21, 2020
@themisir
Copy link
Owner

I still think, you should split required into notNull and notBlank.

I think value of TextFormField never equals to null.

@masseelch
Copy link
Contributor Author

masseelch commented Aug 24, 2020

I think value of TextFormField never equals to null.

If one would create a custom form field (like i did with a signature-field), it can return null as value. In that case the required validator would not work. It now checks for length, my custom type in a custom form field might not have a length property.

@themisir
Copy link
Owner

themisir commented Aug 25, 2020

I think value of TextFormField never equals to null.

If one would create a custom form field (like i did with a signature-field), it can return null as value. In that case the required validator would not work. It now checks for length, my custom type in a custom form field might not have a length property.

😅 may you reopen the PR? I'll merge it after changing a bit.

@masseelch
Copy link
Contributor Author

I somehow managed to delete my fork from my account 😅.

I will fork again and create a new one. Still have a local copy.

@themisir
Copy link
Owner

themisir commented Aug 25, 2020

Ok, don't worry I'll write myself. Btw thanks for PR. I will use ValidationBuilder(optional: true | false) parameter to validate not null and use required to validate value.length > 0.

@iksent
Copy link

iksent commented Dec 4, 2020

Hello, @themisir!

When are you planning to release the new version?

"required"-validator does not work for TextEditingController, because it has an empty string as initial value, but "required"-validator checks for null.

UPD: But for now I use the extension and everything works. Thanks for the cool library!

extension CustomValidationBuilder on ValidationBuilder {
  ValidationBuilder notBlank() => add((value) {
    if (value == null || value.isEmpty) {
      return requiredMessage;
    }
    return null;
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants