-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
[General]: non-required fields became required in v11.0.0 #116
Comments
Yes @techouse, the What do you think that are the best way to write this on README? We are open to change |
Maybe @martijn00 can join to this discussion |
I'm not quite sure why this change was even done as we already had If nothing else some sort of migration document should be created highlighting the change. |
This change was done because null check behaviour was inconstant between a lot of the validators. It made sense for me to have Feel free to submit a PR to clarify the behaviour. |
So in other words, an internal implementation detail is the culprit of this external API change. 😧 Right, I'll do my best to write up a migration guide. |
Sorry for that @techouse. We try to improve the package but maybe this behaviour isn't the best. What do you think about |
This will break A LOT of logic. A breaking change like this should not be a footnote in a wall of text. 😅
Possibly, but that defeats @martijn00's work. 😅 Could you maybe add an option to set this boolean globally or via targets:
$default:
builders:
form_builder_validators:
options:
check_null_or_empty: false or some other way of global delivery?
Well, in v11 it certainly doesn't make any logical sense to have both |
It's not just an implementation detail. Half of the validators would just blow up and crash when using null or empty. That's a big bug and solved by this implementation. I could look into making the behaviour the other way around, but that has side effects as well. This was a major version update so it is acceptable to make a breaking change that benefits future users. Let's have an open discussion about the best way to handle this generically and then see if it needs to be implemented. |
Agreed. There is no simple answer here. |
It just dawned on me that this could be mitigated with What do you guys think? |
It could maybe be migrated with dart fix, but that would probably confuse usage. If you think about the expected behaviour of validators, how would it be? Would all accept a null or empty value as valid? In most cases you don't want that, but depending on your app on some you do. That's why there is a property for it. There is definitely a need for better documentation on this. I'm just struggling to find a different way to handle this in the code. On itself the |
I think the intuitive behaviour here would be to let And I guess it then would be fine to leave it default to true and present on each validator. I would remove the parameter in this case though. Every validator should be able to valiadte any value, including empty ones. It is just that a |
FormBuilderValidators.maxLength(64) should not throw a error even if its empty or null, it does not make sense |
ugh, yeah this was a bit of a weird change for sure. as far as i can tell, most of the places where i had both a min and a max length validator, everything was fine. but in places with just 1 max length validator, my essentially optional fields became required ones. oh well, i should have read the changelog a bit better + had UI tests? :'D but i gotta say: maybe it would have been better with default: false? |
Is there an existing issue for this?
Package/Plugin version
11.0.0
Platforms
Flutter doctor
Flutter doctor
Minimal code example
Code sample
Current Behavior
With v11 this field became required even though
FormBuilderValidators.required()
was not one of the validators.Expected Behavior
Before v11 this field was not required and would allow the user to skip it.
Steps To Reproduce
Aditional information
With regards to the breaking changes in v11, I would have thought that non-required fields would have behaved the same.
Does this now mean that
checkNullOrEmpty
effectively replacesFormBuilderValidators.required()
? If so, could the documentation highlight this change?The text was updated successfully, but these errors were encountered: