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

allowNull flag for CompareValidator #476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omj-denis
Copy link

Connection with issue(s)

Close #473

Solution description

Allow null values for CompareValidator.

Use case example: a shopping application. User can specify price range to search for matching products. If either min or max prices are null, that's fine - this side of the search filter won't be limited. But if both are specified, a validation is needed (expected: min <= max).

Possible workarounds for this functionality are verbose:

  • either a CompareValidator should be duplicated as a custom validator (allowing nulls)
  • or composeOR can be used in combination with a custom AllowNullValidator (reports VALID if value is null thus suppressing CompareValidator report)

Due to the verbosity of workaround solutions, it would be more convenient to have this option implemented in the library 🙏

Also, please see PR #451 with a similar approach applied to NumberValidator.

To Do

  • Check the original issue to confirm it is fully satisfied
  • Add solution description to help guide reviewers
  • Add unit test to verify new or fixed behaviour
  • If apply, add documentation to code properties and package readme

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.

Conditional Date Validation in Flutter
1 participant