You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I hope this message finds you well. I am reaching out to inquire about a feature implementation in Ajv that I couldn't find documented or readily available.
I am currently working on a project where I need to validate certain data using Ajv. In particular, I am interested in implementing validation rules that involve multiple conditions, each with its own unique error message.
For example, consider the following schema snippet:
{
"type": "string",
"minLength": 8,
"format": {
"oneUpper": "(?=.[A-Z])",
"oneLower": "(?=.[a-z])",
"oneNumber": "(?=.[0-9])",
"oneSpecial": "(?=.[^a-zA-Z0-9])"
},
"errorMessage": {
"minLength": "Password must be at least 8 characters long.",
"format": {
"oneUpper": "Password must contain at least one uppercase letter.",
"oneLower": "Password must contain at least one lowercase letter.",
"oneNumber": "Password must contain at least one number.",
"oneSpecial": "Password must contain at least one special character."
}
}
}
As you can see, this schema defines multiple conditions for validating a password, with each condition having its own custom error message.
Could you please advise me on how to achieve this functionality with Ajv? I couldn't find any clear documentation or examples on implementing such complex validations with unique error messages.
Any guidance, examples, or documentation pointers would be greatly appreciated. Thank you for your time and assistance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I hope this message finds you well. I am reaching out to inquire about a feature implementation in Ajv that I couldn't find documented or readily available.
I am currently working on a project where I need to validate certain data using Ajv. In particular, I am interested in implementing validation rules that involve multiple conditions, each with its own unique error message.
For example, consider the following schema snippet:
{
"type": "string",
"minLength": 8,
"format": {
"oneUpper": "(?=.[A-Z])",
"oneLower": "(?=.[a-z])",
"oneNumber": "(?=.[0-9])",
"oneSpecial": "(?=.[^a-zA-Z0-9])"
},
"errorMessage": {
"minLength": "Password must be at least 8 characters long.",
"format": {
"oneUpper": "Password must contain at least one uppercase letter.",
"oneLower": "Password must contain at least one lowercase letter.",
"oneNumber": "Password must contain at least one number.",
"oneSpecial": "Password must contain at least one special character."
}
}
}
As you can see, this schema defines multiple conditions for validating a password, with each condition having its own custom error message.
Could you please advise me on how to achieve this functionality with Ajv? I couldn't find any clear documentation or examples on implementing such complex validations with unique error messages.
Any guidance, examples, or documentation pointers would be greatly appreciated. Thank you for your time and assistance.
Best Regards,
Ajay.
Beta Was this translation helpful? Give feedback.
All reactions