Immediate.Validations conditional validators and delegates
Trying to reimplement some of my FluentValidation rules in IV and a lot of my rules depend on
.When()
and Must()
. I see that AdditionalValidators
is something I can define but the example in the docs makes it look like a lot of boilerplate in comparison13 Replies
keep in mind that you can create your own attribute validators for use as well
If I do and it feels like a common thing, such as "Valid File Path", should I submit a PR?
in your case, if you want to validate an IPAddress, then you could do something like:
then you can apply it like:
Oh I see, that's less work than I thought it would be
valid file path probably would not make it in, since that's actually fairly application specific (unix vs windows, is there an abstraction layer of some kind that changes what a "valid" file path is, etc.)
Fair. What about conditional validation? I.e. only care about property B if property A is true
haven't really run into that very often, and i usually just do that via
AdditionalValidations
Yeah I have a lot of that in my startup options
you could write a multi-rgument validator
Like I can pass other properties into a validator?
Ah
nameof
okay got it
Okay awesome well that's super nice
Thanks!see this section for more info on that: https://github.com/ImmediatePlatform/Immediate.Validations?tab=readme-ov-file#referencing-other-properties