I am using AJV for custom validation. I want to change the error message as well while validate, I am using -
<script src="https://cdnjs.cloudflare.com/ajax/libs/ajv/6.11.0/ajv.min.js"></script>
var imageValidation = {
required: ['name', 'url', 'source','tags'],
properties: {
name: {type: 'string'},
url: {
type: 'string',
pattern: "(^s3\:\/\/.+(jpeg|JPEG|jpg|JPG)$)",
errorMessage: {
type:'must be a string',
pattern: "Image extension should match with jpeg, JPEG, jpg, JPG format"
}
// messages: {
// pattern: 'Image extention should match with jpeg, JPEG, jpg, JPG format'
// }
// message: "Image extention should match with jpeg, JPEG, jpg, JPG format"
},
source: {type: 'string'},
tags: {type: 'array'}
}
allRequired: true
};
I am getting each and every time default error message provided by AJV. I am excepting - My Error message should be -
Image extension should match with jpeg, JPEG, jpg, JPG format
Also tried with message attributes. Same issue. Am I doing something wrong, Or do I need to import some scripts ?