hey! I create ajvFormats and want to change default error display
currently for example I have :
must match format “email”
I’ve added translator to display keys in jsonforms and see this but nothing else
Can you confirm that I’ve to use
must match format “email”
as the translate key ?
my ajv
const formats = {
email: {
type: ‘string’,
validate: (data: string) => /[1]+@[^\s@]+.[^\s@]+$/.test(data),
errorMessageKey: ‘validation_emailInvalid’,
errorMessage: “URL invalid - must begin with https://”,
},
phone: {
type: ‘string’,
validate: (data: string) => /^+[0-9]+$/.test(data),
errorMessageKey: ‘validation_phoneInvalid’,
errorMessage: “URL invalid - must begin with https://”,
},
url: {
type: ‘string’,
validate: (data: string) => /^https://.+/.test(data),
error: {
message: “ddddd”
},
errorMessageKey: ‘validation_urlInvalid’,
errorMessage: “URL invalid - must begin with https://”,
},
xlinkedin: {
type: ‘string’,
validate: (data: string) => /^https://(www.)?linkedin.com/(in|company)/[\w-]+/?$/.test(data),
errorMessageKey: ‘validation_linkedinInvalid’,
errorMessage: “URL invalid - must begin with https://”,
},};
export const xcreateAjv = () => {
const myAjv = new Ajv({
//createAjv({
allErrors: true,
verbose: true,
$data: true,
strict: false,
messages: true
});
ajvErrors(myAjv);
addFormats(myAjv);
Object.entries(formats).forEach(([name, format]) => {
myAjv.addFormat(name, format.validate);
const schema = {
type: 'string',
format: name,
errorMessage: {
format: format.errorMessage
}
};
myAjv.addSchema(schema, `${name}Schema`);
});
// errorMessage: String(i18n.t(format.errorMessageKey)),//{
//format: String(i18n.t(format.errorMessageKey))
//format: String(format.errorMessageKey)
//}
^\s@ ↩︎