Replies: 1 comment
-
For anyone interested, this is my own TS implementation (note that some types in use are actually Vee-validate internal types I was forced to replicate in my own project): /**
* Rule that makes a field required if another field is set to a certain value.
* @param otherField - name of the field to compare with
* @param valueOfOtherField - value of the other field that forces the current field to be required
*/
export function required_if(otherField: string, valueOfOtherField: unknown): GenericValidateFunction {
return (value: unknown, ctx: FieldValidationMetaInfo) => {
if (isEmpty(ctx.form[otherField]) || ctx.form[otherField] !== valueOfOtherField)
return true
return required(value, ctx)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
required_if
validator is mentioned in rules package README and in most translation files but it is actually nowhere to find.Was it actually removed and what I see is just some remnants of the past ?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions