Closed thetutlage closed 8 months ago
requiredIfExistsAny
and requiredIfMissingAny
sound weird to me. wouldn't requiredIfAnyExists
and requiredIfAnyMissing
be more appropriate?
maybe it's my English that's lacking here, so tell me if i am wrong
otherwise, looks perfect. cool and simpler alternative to unions 👌
requiredIfExistsAny and requiredIfMissingAny sound weird to me. wouldn't requiredIfAnyExists and requiredIfAnyMissing be more appropriate?
Yeah, your variation seems more natural to speak. Let's see if @RomainLanz thinks the same and then I can update the method names.
I agree with @Julien-R44, requiredIfAnyExists
and requiredIfAnyMissing
sounds more natural. 👍🏻
The
requiredIf
rules offer an alternate API to thevine.union
which is less type-safe but also simpler to write and express conditions.Here's a quick example between the
vine.union
and therequiredIf
rules.With
vine.union
The output type will be a union as well.
With
requiredIfMissing
The output will have both
email
andphone
as optional even though one of them will be defined at runtime.The
requiredIfMissing
rules are helpful when you do not care much about the output data-types and you do not want to narrow them. For example, validate data and store it as a JSON blob in the database