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
Validators boolean logic #329
Comments
Hello @skryja it's a little hard not knowing what the custom function do, but will try to layout the operations that should occur for the Block1 & Block2 below are Block1
Block2
it seems odd to me to have 2 validations here, and that I hope this helps, please let me know :) |
Thanks @joeybloggs for your answer, |
Hey @skryja I may have solved this in a dream ;) one thing I realized was the Maybe I’m way off? |
Hey @skryja I have confirmed that this is a bug and is due to the way I was checking when to terminate each or instance; will be fixed soon, nice catch 😄 |
Thanks @skryja for reporting, it should now be fixed in v9.9.1 release, please update and try again if you have any more problems with it please let me know 😄 |
Thanks @joeybloggs ...now it works! :)
If you want to take a look at what isfield and attrpath validators do; also you can check our repo here. Thanks again for your time 😃 |
@skryja Thanks for that ! always interested in seeing how others are using it :) I may even add a few after seeing your like prefix and suffix validations. oh and I noticed your issue 37 about the required tag failing, there are a few issue, think one still open tagged question, that explains required’s behavior, but to paraphrase: required checks that the field is not the field types default value, for bool false, int 0, string “” and so forth. It doesn’t make much sense on a bool unless you need it tri-state and for that you would use a pointer to a bool. In fact if you have optional variables that’s how you would handle if they were actually set or not as the default value of a pointer is nil(yes nil is a type) |
Package version eg. v8, v9:
v9
Issue, Question or Enhancement:
I'm trying to test a struct with validation tags but i can't understand how the boolean logic works.
In this example it's expected that the validator on the Path attribute returns false value, but i don't know how it returns true, because the require.Error in TestPatchOpValid fails.
I'm using two custom tags:
isfield: it checks if a struct's attribute has a certain value (eg. isfield=Op:remove)
attrpath: it checks if the value has a correct composition (it's not so important in this case)
Have you an explanation for the validators' logic?
Code sample, to showcase or reproduce:
The text was updated successfully, but these errors were encountered: