mirror of
https://github.com/strapi/strapi.git
synced 2025-12-17 18:25:40 +00:00
feat(helper-plugin): getYupInnerErrors use yup params in error messaging
This commit is contained in:
parent
253ba050a7
commit
e2d8282e81
@ -526,10 +526,10 @@
|
|||||||
"components.Input.error.validation.email": "Value is an invalid email",
|
"components.Input.error.validation.email": "Value is an invalid email",
|
||||||
"components.Input.error.validation.json": "Value is invalid JSON",
|
"components.Input.error.validation.json": "Value is invalid JSON",
|
||||||
"components.Input.error.validation.lowercase": "The value must be a lowercase string",
|
"components.Input.error.validation.lowercase": "The value must be a lowercase string",
|
||||||
"components.Input.error.validation.max": "Value is larger than the maximum",
|
"components.Input.error.validation.max": "Value is larger than the maximum {max}",
|
||||||
"components.Input.error.validation.maxLength": "Value is longer than the maximum",
|
"components.Input.error.validation.maxLength": "Value is longer than the maximum length {max}",
|
||||||
"components.Input.error.validation.min": "Value is smaller than the minimum",
|
"components.Input.error.validation.min": "Value is smaller than the minimum {min}",
|
||||||
"components.Input.error.validation.minLength": "Value is shorter than the minimum",
|
"components.Input.error.validation.minLength": "Value is shorter than the minimum length {min}",
|
||||||
"components.Input.error.validation.minSupMax": "Value cannot be superior",
|
"components.Input.error.validation.minSupMax": "Value cannot be superior",
|
||||||
"components.Input.error.validation.regex": "Value does not match the required pattern",
|
"components.Input.error.validation.regex": "Value does not match the required pattern",
|
||||||
"components.Input.error.validation.required": "Value is required",
|
"components.Input.error.validation.required": "Value is required",
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { get } from 'lodash';
|
|
||||||
|
|
||||||
const getYupInnerErrors = (error) => {
|
const getYupInnerErrors = (error) => {
|
||||||
return get(error, 'inner', []).reduce((acc, curr) => {
|
return (error?.inner || []).reduce((acc, currentError) => {
|
||||||
acc[curr.path.split('[').join('.').split(']').join('')] = {
|
acc[currentError.path.split('[').join('.').split(']').join('')] = {
|
||||||
id: curr.message,
|
id: currentError.message,
|
||||||
defaultMessage: curr.message,
|
defaultMessage: currentError.message,
|
||||||
|
values: Object.keys(currentError?.params || {})
|
||||||
|
.filter((key) => !['label', 'originalValue', 'path', 'value'].includes(key))
|
||||||
|
.reduce((current, key) => Object.assign(current, { [key]: currentError.params[key] }), {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user