-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
87 lines (85 loc) · 2.88 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Internal methods
function translateError(message) {
return message
.replace(
/^Data passed to validate is incorrect. It must be an object$/ig,
'Los datos a validar son incorrectos. Se esperaba un objeto.'
)
.replace(
/^Property ([a-z0-9_.]+) is (number|string|boolean|object|function), expected (number|string|boolean|object)$/ig,
'La propiedad $1 es de tipo $2, se esperaba $3'
)
.replace(
/^Property ([a-z0-9_.]+) not valid in schema$/ig,
'La propiedad $1 no está permitida en el esquema'
)
.replace(
/^Custom validation failed for property ([a-z0-9_.]+)`$/ig,
'Falló la validación para $1'
)
.replace(
/^Missing required property ([a-z0-9_.]+)/ig,
'Falta una propiedad requerida: $1'
)
.replace(
/^Property ([a-z0-9_.]+) is not a valid date$/ig,
'La propiedad $1 no es una fecha válida'
)
.replace(
/^Property ([a-z0-9_.]+) must contain at least ([0-9]+) characters$/ig,
'La propiedad $1 debe contener al menos $2 caracteres'
)
.replace(
/^Property ([a-z0-9_.]+) must contain less than ([0-9]+) characters$/ig,
'La propiedad $1 debe contener menos de $2 caracteres'
)
.replace(
/^Property ([a-z0-9_.]+) must be greater than ([0-9]+)$/ig,
'La propiedad $1 debe ser mayor que $2'
)
.replace(
/^Property ([a-z0-9_.]+) must be less than ([0-9]+)$/ig,
'La propiedad $1 debe ser menor que $2'
)
.replace(
/^Regex validation failed for property ([a-z0-9_.]+)$/ig,
'Fallo la validacion para la propiedad $1'
)
.replace(
/^Value of property ([a-z0-9_.]+) does not contain an acceptable value$/ig,
'El valor para la propiedad $1 no está entre los valores aceptados'
)
.replace(
/^Property ([a-z0-9_.]+) is not a valid uuid\/(v1|v4)$/ig,
'La propiedad $1 no es un formato uuid/$2 válido'
)
.replace(
/^Property ([a-z0-9_.]+) is (number|string|boolean|object|function), expected array$/ig,
'La propiedad $1 es de tipo $2, se esperaba un array'
)
.replace(
/^An item in array of property ([a-z0-9_.]+) is not valid$/ig,
'Un elemento en la propiedad $1 no es válido'
)
.replace(
/^An item in array of property ([a-z0-9_.]+) is not valid. All items must be of type (number|string|boolean|object|function)}$/ig,
'Un elemento en la propiedad $1 no es válido. Todos los elementos deben ser de tipo $2'
)
.replace(
/^Property ([a-z0-9_.]+) must contain at least ([0-9]+) elements$/ig,
'La propiedad $1 debe contener por lo menos $2 elementos'
)
.replace(
/^Property ([a-z0-9_.]+) must contain no more than ([0-9]+) elements$/ig,
'La propiedad $1 debe contener no más de $2 elementos'
)
.replace(
/^Cannot validate empty object$/ig,
'No se puede validar un objeto vacío'
);
}
// Schemy events handlers
function getValidationErrors() {
this.validationErrors = this.validationErrors.map(error => translateError(error));
}
module.exports = { getValidationErrors };