-
Notifications
You must be signed in to change notification settings - Fork 9
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
Method Validator Ignores Null Values / Empty Strings #13
Comments
I think it makes sense. Things get blurry for me amigo once you have so many validators |
Thanks @lmajano, so you recommend we leave them as is? Thus the |
I propose we change them to be consistent.
Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com
Social: twitter.com/lmajano facebook.com/lmajano
…On Tue, Jun 13, 2023 at 10:23 PM Dave L ***@***.***> wrote:
Thanks @lmajano <https://github.com/lmajano>, so you recommend we leave
them as is? Therefore method ignores nulls/empty, but udf does not? Or do
you propose we change them to be consistent?
—
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABBPF5ZI5MV3I5A5XLXUATXLDD4HANCNFSM6AAAAAAZFMJLJM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sounds good. I will run a few experiments and then create a PR. Stay tuned. :) |
Created a PR to handle null/empty values that developers can switch to if the UDF validator will treat nulls as valid. Developers should switch to using I still feel uneasy about implementing the change to the UDF validator, however I can't deny that it does make it more consistent with other validators. |
This is a breaking change designed to make the UDF validator consistent with other validators as discussed here (ortus-docs/cbvalidation-docs#13). Developers should switch to the `requiredIf` validator if they need to dynamically evaluate whether a field should be required or not.
While I was updating the documentation, I noticed the
method
validator ignores empty/null values. This puzzled me because theudf
validator does not ignore empty/null values. I always thought theudf
andmethod
validators were similar and could be used interchangeably if you required a more complex function that you wanted to break out from the constraints struct.Should we allow null/empty strings to pass through to the method and let it decide what to do about null values? In 95% of my
udf
validators I check for a null/empty value and return true, so maybe themethod
validator is the one doing it correctly? I see arguments for both approaches so I'm not sure what the best way to proceed is, so I would love some feedback/suggestions.Method Validator:
https://github.com/coldbox-modules/cbvalidation/blob/0a8dbe8355cfbd4e20db90d0c3be9b2f592b6a2f/models/validators/MethodValidator.cfc#L36-L44
The text was updated successfully, but these errors were encountered: