schema-dsl 1.0.0 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +263 -529
  2. package/README.md +814 -896
  3. package/STATUS.md +135 -2
  4. package/docs/INDEX.md +1 -2
  5. package/docs/api-reference.md +1 -292
  6. package/docs/custom-extensions-guide.md +411 -0
  7. package/docs/enum.md +475 -0
  8. package/docs/i18n.md +394 -0
  9. package/docs/performance-benchmark-report.md +179 -0
  10. package/docs/plugin-system.md +8 -8
  11. package/docs/typescript-guide.md +554 -0
  12. package/docs/validate-async.md +1 -1
  13. package/docs/validation-rules-v1.0.2.md +1601 -0
  14. package/examples/README.md +81 -0
  15. package/examples/enum.examples.js +324 -0
  16. package/examples/express-integration.js +54 -54
  17. package/examples/i18n-full-demo.js +15 -24
  18. package/examples/schema-utils-chaining.examples.js +2 -2
  19. package/examples/slug.examples.js +179 -0
  20. package/index.d.ts +246 -17
  21. package/index.js +30 -34
  22. package/lib/config/constants.js +1 -1
  23. package/lib/config/patterns/common.js +47 -0
  24. package/lib/config/patterns/index.js +2 -1
  25. package/lib/core/DslBuilder.js +500 -8
  26. package/lib/core/StringExtensions.js +31 -0
  27. package/lib/core/Validator.js +42 -15
  28. package/lib/errors/ValidationError.js +3 -3
  29. package/lib/locales/en-US.js +79 -19
  30. package/lib/locales/es-ES.js +60 -19
  31. package/lib/locales/fr-FR.js +84 -43
  32. package/lib/locales/ja-JP.js +83 -42
  33. package/lib/locales/zh-CN.js +32 -0
  34. package/lib/validators/CustomKeywords.js +405 -0
  35. package/package.json +1 -1
  36. package/.github/CODE_OF_CONDUCT.md +0 -45
  37. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -57
  38. package/.github/ISSUE_TEMPLATE/config.yml +0 -11
  39. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -45
  40. package/.github/ISSUE_TEMPLATE/question.md +0 -31
  41. package/.github/PULL_REQUEST_TEMPLATE.md +0 -70
  42. package/.github/SECURITY.md +0 -184
  43. package/.github/workflows/ci.yml +0 -33
  44. package/plugins/custom-format.js +0 -101
  45. package/plugins/custom-validator.js +0 -200
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
+ // Generic
2
3
  required: '{{#label}} is required',
3
4
  type: '{{#label}} should be {{#expected}}, got {{#actual}}',
4
5
  min: '{{#label}} length must be at least {{#limit}}',
@@ -11,12 +12,80 @@ module.exports = {
11
12
  'max-depth': 'Maximum recursion depth ({{#depth}}) exceeded at {{#label}}',
12
13
  exception: '{{#label}} validation exception: {{#message}}',
13
14
 
14
- // Patterns
15
+ // Formats
16
+ 'format.email': '{{#label}} must be a valid email address',
17
+ 'format.url': '{{#label}} must be a valid URL',
18
+ 'format.uuid': '{{#label}} must be a valid UUID',
19
+ 'format.date': '{{#label}} must be a valid date (YYYY-MM-DD)',
20
+ 'format.datetime': '{{#label}} must be a valid date-time (ISO 8601)',
21
+ 'format.time': '{{#label}} must be a valid time (HH:mm:ss)',
22
+ 'format.ipv4': '{{#label}} must be a valid IPv4 address',
23
+ 'format.ipv6': '{{#label}} must be a valid IPv6 address',
24
+ 'format.binary': '{{#label}} must be a valid base64 string',
25
+
26
+ // String
27
+ 'string.hostname': '{{#label}} must be a valid hostname',
28
+ 'string.pattern': '{{#label}} format does not match required pattern',
29
+ 'string.enum': '{{#label}} must be one of: {{#valids}}',
30
+ // v1.0.2
31
+ 'string.length': '{{#label}} length must be exactly {{#limit}} characters',
32
+ 'string.alphanum': '{{#label}} must only contain alphanumeric characters',
33
+ 'string.trim': '{{#label}} must not have leading or trailing whitespace',
34
+ 'string.lowercase': '{{#label}} must be lowercase',
35
+ 'string.uppercase': '{{#label}} must be uppercase',
36
+
37
+ // Number
38
+ 'number.base': '{{#label}} must be a number',
39
+ 'number.min': '{{#label}} must be greater than or equal to {{#limit}}',
40
+ 'number.max': '{{#label}} must be less than or equal to {{#limit}}',
41
+ 'number.integer': '{{#label}} must be an integer',
42
+ 'number.positive': '{{#label}} must be a positive number',
43
+ 'number.negative': '{{#label}} must be a negative number',
44
+ // v1.0.2
45
+ 'number.precision': '{{#label}} must have at most {{#limit}} decimal places',
46
+ 'number.port': '{{#label}} must be a valid port number (1-65535)',
47
+
48
+ // Boolean
49
+ 'boolean.base': '{{#label}} must be a boolean',
50
+
51
+ // Object
52
+ 'object.base': '{{#label}} must be an object',
53
+ 'object.min': '{{#label}} must have at least {{#limit}} properties',
54
+ 'object.max': '{{#label}} must have at most {{#limit}} properties',
55
+ 'object.unknown': '{{#label}} contains unknown property: {{#key}}',
56
+ // v1.0.2
57
+ 'object.missing': '{{#label}} is missing required properties',
58
+ 'object.schema': '{{#label}} contains additional properties',
59
+
60
+ // Array
61
+ 'array.base': '{{#label}} must be an array',
62
+ 'array.min': '{{#label}} must have at least {{#limit}} items',
63
+ 'array.max': '{{#label}} must have at most {{#limit}} items',
64
+ 'array.length': '{{#label}} must have exactly {{#limit}} items',
65
+ 'array.unique': '{{#label}} must not contain duplicate items',
66
+ // v1.0.2
67
+ 'array.sparse': '{{#label}} must not be a sparse array',
68
+ 'array.includesRequired': '{{#label}} must include required items',
69
+
70
+ // Date
71
+ 'date.base': '{{#label}} must be a valid date',
72
+ 'date.min': '{{#label}} must be no earlier than {{#limit}}',
73
+ 'date.max': '{{#label}} must be no later than {{#limit}}',
74
+ // v1.0.2
75
+ 'date.format': '{{#label}} date format is invalid',
76
+ 'date.greater': '{{#label}} must be after {{#limit}}',
77
+ 'date.less': '{{#label}} must be before {{#limit}}',
78
+
79
+ // Any
80
+ 'any.required': '{{#label}} is required',
81
+ 'any.invalid': '{{#label}} contains an invalid value',
82
+ 'any.only': '{{#label}} must match {{#valids}}',
83
+ 'any.unknown': 'Field {{#key}} is not allowed',
84
+
85
+ // Patterns (Legacy/Specific)
15
86
  'pattern.phone': 'Invalid phone number',
16
87
  'pattern.phone.international': 'Invalid international phone number',
17
-
18
88
  'pattern.idCard': 'Invalid ID card number',
19
-
20
89
  'pattern.creditCard': 'Invalid credit card number',
21
90
  'pattern.creditCard.visa': 'Invalid Visa card number',
22
91
  'pattern.creditCard.mastercard': 'Invalid Mastercard number',
@@ -24,19 +93,20 @@ module.exports = {
24
93
  'pattern.creditCard.discover': 'Invalid Discover card number',
25
94
  'pattern.creditCard.jcb': 'Invalid JCB card number',
26
95
  'pattern.creditCard.unionpay': 'Invalid UnionPay card number',
27
-
28
96
  'pattern.licensePlate': 'Invalid license plate number',
29
-
30
97
  'pattern.postalCode': 'Invalid postal code',
31
-
32
98
  'pattern.passport': 'Invalid passport number',
33
-
34
- // New Types
35
99
  'pattern.objectId': 'Invalid ObjectId',
36
100
  'pattern.hexColor': 'Invalid Hex Color',
37
101
  'pattern.macAddress': 'Invalid MAC Address',
38
102
  'pattern.cron': 'Invalid Cron Expression',
39
103
  'pattern.slug': 'URL slug can only contain lowercase letters, numbers, and hyphens',
104
+ // v1.0.2 新增
105
+ 'pattern.domain': '{{#label}} must be a valid domain name',
106
+ 'pattern.ip': '{{#label}} must be a valid IP address',
107
+ 'pattern.base64': '{{#label}} must be a valid Base64 string',
108
+ 'pattern.jwt': '{{#label}} must be a valid JWT token',
109
+ 'pattern.json': '{{#label}} must be a valid JSON string',
40
110
 
41
111
  // Username & Password
42
112
  'pattern.username': 'Username must start with a letter and contain only letters, numbers, and underscores',
@@ -51,15 +121,5 @@ module.exports = {
51
121
  // Custom validation
52
122
  'CUSTOM_VALIDATION_FAILED': 'Validation failed',
53
123
  'ASYNC_VALIDATION_NOT_SUPPORTED': 'Async validation not supported in synchronous validate()',
54
- 'VALIDATE_MUST_BE_FUNCTION': 'validate must be a function',
55
-
56
- // Formats
57
- 'format.email': '{{#label}} must be a valid email address',
58
- 'format.url': '{{#label}} must be a valid URL',
59
- 'format.uuid': '{{#label}} must be a valid UUID',
60
- 'format.date': '{{#label}} must be a valid date (YYYY-MM-DD)',
61
- 'format.datetime': '{{#label}} must be a valid date-time (ISO 8601)',
62
- 'format.time': '{{#label}} must be a valid time (HH:mm:ss)',
63
- 'format.ipv4': '{{#label}} must be a valid IPv4 address',
64
- 'format.ipv6': '{{#label}} must be a valid IPv6 address'
124
+ 'VALIDATE_MUST_BE_FUNCTION': 'validate must be a function'
65
125
  };
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
+ // Generic
2
3
  required: '{{#label}} es obligatorio',
3
4
  type: '{{#label}} debe ser de tipo {{#expected}}, pero se obtuvo {{#actual}}',
4
5
  min: 'La longitud de {{#label}} debe ser al menos {{#limit}}',
@@ -11,12 +12,61 @@ module.exports = {
11
12
  'max-depth': 'Profundidad máxima de recursión ({{#depth}}) excedida en {{#label}}',
12
13
  exception: 'Excepción de validación en {{#label}}: {{#message}}',
13
14
 
14
- // Patterns
15
+ // Formats
16
+ 'format.email': '{{#label}} debe ser una dirección de correo electrónico válida',
17
+ 'format.url': '{{#label}} debe ser una URL válida',
18
+ 'format.uuid': '{{#label}} debe ser un UUID válido',
19
+ 'format.date': '{{#label}} debe ser una fecha válida (YYYY-MM-DD)',
20
+ 'format.datetime': '{{#label}} debe ser una fecha y hora válida (ISO 8601)',
21
+ 'format.time': '{{#label}} debe ser una hora válida (HH:mm:ss)',
22
+ 'format.ipv4': '{{#label}} debe ser una dirección IPv4 válida',
23
+ 'format.ipv6': '{{#label}} debe ser una dirección IPv6 válida',
24
+ 'format.binary': '{{#label}} debe ser una cadena base64 válida',
25
+
26
+ // String
27
+ 'string.hostname': '{{#label}} debe ser un nombre de host válido',
28
+ 'string.pattern': 'El formato de {{#label}} no coincide con el patrón requerido',
29
+ 'string.enum': '{{#label}} debe ser uno de: {{#valids}}',
30
+
31
+ // Number
32
+ 'number.base': '{{#label}} debe ser un número',
33
+ 'number.min': '{{#label}} debe ser mayor o igual a {{#limit}}',
34
+ 'number.max': '{{#label}} debe ser menor o igual a {{#limit}}',
35
+ 'number.integer': '{{#label}} debe ser un número entero',
36
+ 'number.positive': '{{#label}} debe ser un número positivo',
37
+ 'number.negative': '{{#label}} debe ser un número negativo',
38
+
39
+ // Boolean
40
+ 'boolean.base': '{{#label}} debe ser un booleano',
41
+
42
+ // Object
43
+ 'object.base': '{{#label}} debe ser un objeto',
44
+ 'object.min': '{{#label}} debe tener al menos {{#limit}} propiedades',
45
+ 'object.max': '{{#label}} debe tener como máximo {{#limit}} propiedades',
46
+ 'object.unknown': '{{#label}} contiene una propiedad desconocida: {{#key}}',
47
+
48
+ // Array
49
+ 'array.base': '{{#label}} debe ser un array',
50
+ 'array.min': '{{#label}} debe tener al menos {{#limit}} elementos',
51
+ 'array.max': '{{#label}} debe tener como máximo {{#limit}} elementos',
52
+ 'array.length': '{{#label}} debe tener exactamente {{#limit}} elementos',
53
+ 'array.unique': '{{#label}} no debe contener elementos duplicados',
54
+
55
+ // Date
56
+ 'date.base': '{{#label}} debe ser una fecha válida',
57
+ 'date.min': '{{#label}} no debe ser anterior a {{#limit}}',
58
+ 'date.max': '{{#label}} no debe ser posterior a {{#limit}}',
59
+
60
+ // Any
61
+ 'any.required': '{{#label}} es obligatorio',
62
+ 'any.invalid': '{{#label}} contiene un valor no válido',
63
+ 'any.only': '{{#label}} debe coincidir con {{#valids}}',
64
+ 'any.unknown': 'El campo {{#key}} no está permitido',
65
+
66
+ // Patterns (Legacy/Specific)
15
67
  'pattern.phone': 'Número de teléfono no válido',
16
68
  'pattern.phone.international': 'Número de teléfono internacional no válido',
17
-
18
69
  'pattern.idCard': 'Número de tarjeta de identificación no válido',
19
-
20
70
  'pattern.creditCard': 'Número de tarjeta de crédito no válido',
21
71
  'pattern.creditCard.visa': 'Número de tarjeta Visa no válido',
22
72
  'pattern.creditCard.mastercard': 'Número de Mastercard no válido',
@@ -24,19 +74,20 @@ module.exports = {
24
74
  'pattern.creditCard.discover': 'Número de tarjeta Discover no válido',
25
75
  'pattern.creditCard.jcb': 'Número de tarjeta JCB no válido',
26
76
  'pattern.creditCard.unionpay': 'Número de tarjeta UnionPay no válido',
27
-
28
77
  'pattern.licensePlate': 'Número de matrícula no válido',
29
-
30
78
  'pattern.postalCode': 'Código postal no válido',
31
-
32
79
  'pattern.passport': 'Número de pasaporte no válido',
33
-
34
- // New Types
35
80
  'pattern.objectId': 'ObjectId no válido',
36
81
  'pattern.hexColor': 'Color hexadecimal no válido',
37
82
  'pattern.macAddress': 'Dirección MAC no válida',
38
83
  'pattern.cron': 'Expresión Cron no válida',
39
84
  'pattern.slug': 'El slug de URL solo puede contener letras minúsculas, números y guiones',
85
+ // v1.0.2 新增
86
+ 'pattern.domain': '{{#label}} debe ser un nombre de dominio válido',
87
+ 'pattern.ip': '{{#label}} debe ser una dirección IP válida',
88
+ 'pattern.base64': '{{#label}} debe ser una cadena Base64 válida',
89
+ 'pattern.jwt': '{{#label}} debe ser un token JWT válido',
90
+ 'pattern.json': '{{#label}} debe ser una cadena JSON válida',
40
91
 
41
92
  // Username & Password
42
93
  'pattern.username': 'El nombre de usuario debe comenzar con una letra y contener solo letras, números y guiones bajos',
@@ -51,16 +102,6 @@ module.exports = {
51
102
  // Custom validation
52
103
  'CUSTOM_VALIDATION_FAILED': 'Validación fallida',
53
104
  'ASYNC_VALIDATION_NOT_SUPPORTED': 'La validación asíncrona no es compatible en validate() síncrono',
54
- 'VALIDATE_MUST_BE_FUNCTION': 'validate debe ser una función',
55
-
56
- // Formats
57
- 'format.email': 'Dirección de correo electrónico no válida',
58
- 'format.url': 'URL no válida',
59
- 'format.uuid': 'UUID no válido',
60
- 'format.date': 'Formato de fecha no válido (YYYY-MM-DD)',
61
- 'format.datetime': 'Formato de fecha y hora no válido (ISO 8601)',
62
- 'format.time': 'Formato de hora no válido (HH:mm:ss)',
63
- 'format.ipv4': 'Dirección IPv4 no válida',
64
- 'format.ipv6': 'Dirección IPv6 no válida'
105
+ 'VALIDATE_MUST_BE_FUNCTION': 'validate debe ser una función'
65
106
  };
66
107
 
@@ -1,66 +1,107 @@
1
1
  module.exports = {
2
+ // Generic
2
3
  required: '{{#label}} est requis',
3
- type: '{{#label}} doit être de type {{#expected}}, mais a obtenu {{#actual}}',
4
+ type: '{{#label}} doit être de type {{#expected}}, mais {{#actual}} a été reçu',
4
5
  min: 'La longueur de {{#label}} doit être d\'au moins {{#limit}}',
5
- max: 'La longueur de {{#label}} doit être au maximum de {{#limit}}',
6
+ max: 'La longueur de {{#label}} doit être d\'au plus {{#limit}}',
6
7
  length: 'La longueur de {{#label}} doit être exactement {{#expected}}',
7
- pattern: 'Le format de {{#label}} est invalide',
8
- enum: '{{#label}} doit être l\'un des suivants: {{#allowed}}',
9
- custom: 'Échec de la validation pour {{#label}}: {{#message}}',
8
+ pattern: 'Le format de {{#label}} n\'est pas valide',
9
+ enum: '{{#label}} doit être l\'un de : {{#allowed}}',
10
+ custom: 'Validation échouée pour {{#label}} : {{#message}}',
10
11
  circular: 'Référence circulaire détectée dans {{#label}}',
11
- 'max-depth': 'Profondeur de récursion maximale ({{#depth}}) dépassée dans {{#label}}',
12
- exception: 'Exception de validation dans {{#label}}: {{#message}}',
12
+ 'max-depth': 'Profondeur maximale de récursion ({{#depth}}) dépassée dans {{#label}}',
13
+ exception: 'Exception de validation dans {{#label}} : {{#message}}',
13
14
 
14
- // Patterns
15
- 'pattern.phone': 'Numéro de téléphone invalide',
16
- 'pattern.phone.international': 'Numéro de téléphone international invalide',
15
+ // Formats
16
+ 'format.email': '{{#label}} doit être une adresse e-mail valide',
17
+ 'format.url': '{{#label}} doit être une URL valide',
18
+ 'format.uuid': '{{#label}} doit être un UUID valide',
19
+ 'format.date': '{{#label}} doit être une date valide (YYYY-MM-DD)',
20
+ 'format.datetime': '{{#label}} doit être une date et heure valide (ISO 8601)',
21
+ 'format.time': '{{#label}} doit être une heure valide (HH:mm:ss)',
22
+ 'format.ipv4': '{{#label}} doit être une adresse IPv4 valide',
23
+ 'format.ipv6': '{{#label}} doit être une adresse IPv6 valide',
24
+ 'format.binary': '{{#label}} doit être une chaîne base64 valide',
25
+
26
+ // String
27
+ 'string.hostname': '{{#label}} doit être un nom d\'hôte valide',
28
+ 'string.pattern': 'Le format de {{#label}} ne correspond pas au modèle requis',
29
+ 'string.enum': '{{#label}} doit être l\'un de : {{#valids}}',
30
+
31
+ // Number
32
+ 'number.base': '{{#label}} doit être un nombre',
33
+ 'number.min': '{{#label}} doit être supérieur ou égal à {{#limit}}',
34
+ 'number.max': '{{#label}} doit être inférieur ou égal à {{#limit}}',
35
+ 'number.integer': '{{#label}} doit être un nombre entier',
36
+ 'number.positive': '{{#label}} doit être un nombre positif',
37
+ 'number.negative': '{{#label}} doit être un nombre négatif',
17
38
 
18
- 'pattern.idCard': 'Numéro de carte d\'identité invalide',
39
+ // Boolean
40
+ 'boolean.base': '{{#label}} doit être un booléen',
19
41
 
20
- 'pattern.creditCard': 'Numéro de carte de crédit invalide',
21
- 'pattern.creditCard.visa': 'Numéro de carte Visa invalide',
22
- 'pattern.creditCard.mastercard': 'Numéro Mastercard invalide',
23
- 'pattern.creditCard.amex': 'Numéro de carte American Express invalide',
24
- 'pattern.creditCard.discover': 'Numéro de carte Discover invalide',
25
- 'pattern.creditCard.jcb': 'Numéro de carte JCB invalide',
26
- 'pattern.creditCard.unionpay': 'Numéro de carte UnionPay invalide',
42
+ // Object
43
+ 'object.base': '{{#label}} doit être un objet',
44
+ 'object.min': '{{#label}} doit avoir au moins {{#limit}} propriétés',
45
+ 'object.max': '{{#label}} doit avoir au plus {{#limit}} propriétés',
46
+ 'object.unknown': '{{#label}} contient une propriété inconnue : {{#key}}',
27
47
 
28
- 'pattern.licensePlate': 'Numéro de plaque d\'immatriculation invalide',
48
+ // Array
49
+ 'array.base': '{{#label}} doit être un tableau',
50
+ 'array.min': '{{#label}} doit avoir au moins {{#limit}} éléments',
51
+ 'array.max': '{{#label}} doit avoir au plus {{#limit}} éléments',
52
+ 'array.length': '{{#label}} doit avoir exactement {{#limit}} éléments',
53
+ 'array.unique': '{{#label}} ne doit pas contenir d\'éléments en double',
29
54
 
30
- 'pattern.postalCode': 'Code postal invalide',
55
+ // Date
56
+ 'date.base': '{{#label}} doit être une date valide',
57
+ 'date.min': '{{#label}} ne doit pas être antérieur à {{#limit}}',
58
+ 'date.max': '{{#label}} ne doit pas être postérieur à {{#limit}}',
31
59
 
32
- 'pattern.passport': 'Numéro de passeport invalide',
60
+ // Any
61
+ 'any.required': '{{#label}} est requis',
62
+ 'any.invalid': '{{#label}} contient une valeur non valide',
63
+ 'any.only': '{{#label}} doit correspondre à {{#valids}}',
64
+ 'any.unknown': 'Le champ {{#key}} n\'est pas autorisé',
33
65
 
34
- // New Types
35
- 'pattern.objectId': 'ObjectId invalide',
36
- 'pattern.hexColor': 'Couleur hexadécimale invalide',
37
- 'pattern.macAddress': 'Adresse MAC invalide',
38
- 'pattern.cron': 'Expression Cron invalide',
39
- 'pattern.slug': 'Le slug d\'URL ne peut contenir que des lettres minuscules, des chiffres et des traits d\'union',
66
+ // Patterns (Legacy/Specific)
67
+ 'pattern.phone': 'Numéro de téléphone non valide',
68
+ 'pattern.phone.international': 'Numéro de téléphone international non valide',
69
+ 'pattern.idCard': 'Numéro de carte d\'identité non valide',
70
+ 'pattern.creditCard': 'Numéro de carte de crédit non valide',
71
+ 'pattern.creditCard.visa': 'Numéro de carte Visa non valide',
72
+ 'pattern.creditCard.mastercard': 'Numéro Mastercard non valide',
73
+ 'pattern.creditCard.amex': 'Numéro de carte American Express non valide',
74
+ 'pattern.creditCard.discover': 'Numéro de carte Discover non valide',
75
+ 'pattern.creditCard.jcb': 'Numéro de carte JCB non valide',
76
+ 'pattern.creditCard.unionpay': 'Numéro de carte UnionPay non valide',
77
+ 'pattern.licensePlate': 'Numéro de plaque d\'immatriculation non valide',
78
+ 'pattern.postalCode': 'Code postal non valide',
79
+ 'pattern.passport': 'Numéro de passeport non valide',
80
+ 'pattern.objectId': 'ObjectId non valide',
81
+ 'pattern.hexColor': 'Couleur hexadécimale non valide',
82
+ 'pattern.macAddress': 'Adresse MAC non valide',
83
+ 'pattern.cron': 'Expression Cron non valide',
84
+ 'pattern.slug': 'Le slug d\'URL ne peut contenir que des lettres minuscules, des chiffres et des tirets',
85
+ // v1.0.2 新增
86
+ 'pattern.domain': '{{#label}} doit être un nom de domaine valide',
87
+ 'pattern.ip': '{{#label}} doit être une adresse IP valide',
88
+ 'pattern.base64': '{{#label}} doit être une chaîne Base64 valide',
89
+ 'pattern.jwt': '{{#label}} doit être un token JWT valide',
90
+ 'pattern.json': '{{#label}} doit être une chaîne JSON valide',
40
91
 
41
92
  // Username & Password
42
- 'pattern.username': 'Le nom d\'utilisateur doit commencer par une lettre et ne contenir que des lettres, des chiffres et des traits de soulignement',
93
+ 'pattern.username': 'Le nom d\'utilisateur doit commencer par une lettre et contenir uniquement des lettres, des chiffres et des tirets bas',
43
94
  'pattern.password.weak': 'Le mot de passe doit contenir au moins 6 caractères',
44
- 'pattern.password.medium': 'Le mot de passe doit contenir au moins 8 caractères et contenir des lettres et des chiffres',
45
- 'pattern.password.strong': 'Le mot de passe doit contenir au moins 8 caractères et contenir des lettres majuscules, minuscules et des chiffres',
46
- 'pattern.password.veryStrong': 'Le mot de passe doit contenir au moins 10 caractères et contenir des lettres majuscules, minuscules, des chiffres et des caractères spéciaux',
95
+ 'pattern.password.medium': 'Le mot de passe doit contenir au moins 8 caractères et inclure des lettres et des chiffres',
96
+ 'pattern.password.strong': 'Le mot de passe doit contenir au moins 8 caractères et inclure des lettres majuscules, minuscules et des chiffres',
97
+ 'pattern.password.veryStrong': 'Le mot de passe doit contenir au moins 10 caractères et inclure des lettres majuscules, minuscules, des chiffres et des caractères spéciaux',
47
98
 
48
99
  // Unknown error fallback
49
100
  'UNKNOWN_ERROR': 'Erreur de validation inconnue',
50
101
 
51
102
  // Custom validation
52
- 'CUSTOM_VALIDATION_FAILED': 'Échec de la validation',
103
+ 'CUSTOM_VALIDATION_FAILED': 'Validation échouée',
53
104
  'ASYNC_VALIDATION_NOT_SUPPORTED': 'La validation asynchrone n\'est pas prise en charge dans validate() synchrone',
54
- 'VALIDATE_MUST_BE_FUNCTION': 'validate doit être une fonction',
55
-
56
- // Formats
57
- 'format.email': 'Adresse e-mail invalide',
58
- 'format.url': 'URL invalide',
59
- 'format.uuid': 'UUID invalide',
60
- 'format.date': 'Format de date invalide (YYYY-MM-DD)',
61
- 'format.datetime': 'Format de date et heure invalide (ISO 8601)',
62
- 'format.time': 'Format de l\'heure invalide (HH:mm:ss)',
63
- 'format.ipv4': 'Adresse IPv4 invalide',
64
- 'format.ipv6': 'Adresse IPv6 invalide'
105
+ 'VALIDATE_MUST_BE_FUNCTION': 'validate doit être une fonction'
65
106
  };
66
107
 
@@ -1,66 +1,107 @@
1
1
  module.exports = {
2
+ // Generic
2
3
  required: '{{#label}}は必須です',
3
- type: '{{#label}}は {{#expected}} 型である必要がありますが、{{#actual}} でした',
4
- min: '{{#label}}の長さは少なくとも {{#limit}} である必要があります',
5
- max: '{{#label}}の長さは最大 {{#limit}} である必要があります',
6
- length: '{{#label}}の長さは {{#expected}} である必要があります',
4
+ type: '{{#label}}は{{#expected}}型である必要がありますが、{{#actual}}が渡されました',
5
+ min: '{{#label}}の長さは{{#limit}}以上である必要があります',
6
+ max: '{{#label}}の長さは{{#limit}}以下である必要があります',
7
+ length: '{{#label}}の長さは正確に{{#expected}}である必要があります',
7
8
  pattern: '{{#label}}の形式が無効です',
8
9
  enum: '{{#label}}は次のいずれかである必要があります: {{#allowed}}',
9
10
  custom: '{{#label}}の検証に失敗しました: {{#message}}',
10
11
  circular: '{{#label}}で循環参照が検出されました',
11
12
  'max-depth': '{{#label}}で最大再帰深度 ({{#depth}}) を超えました',
12
- exception: '{{#label}}検証例外: {{#message}}',
13
+ exception: '{{#label}}の検証例外: {{#message}}',
13
14
 
14
- // Patterns
15
- 'pattern.phone': '無効な電話番号です',
16
- 'pattern.phone.international': '無効な国際電話番号です',
15
+ // Formats
16
+ 'format.email': '{{#label}}は有効なメールアドレスである必要があります',
17
+ 'format.url': '{{#label}}は有効なURLである必要があります',
18
+ 'format.uuid': '{{#label}}は有効なUUIDである必要があります',
19
+ 'format.date': '{{#label}}は有効な日付 (YYYY-MM-DD) である必要があります',
20
+ 'format.datetime': '{{#label}}は有効な日時 (ISO 8601) である必要があります',
21
+ 'format.time': '{{#label}}は有効な時刻 (HH:mm:ss) である必要があります',
22
+ 'format.ipv4': '{{#label}}は有効なIPv4アドレスである必要があります',
23
+ 'format.ipv6': '{{#label}}は有効なIPv6アドレスである必要があります',
24
+ 'format.binary': '{{#label}}は有効なbase64文字列である必要があります',
25
+
26
+ // String
27
+ 'string.hostname': '{{#label}}は有効なホスト名である必要があります',
28
+ 'string.pattern': '{{#label}}の形式が必要なパターンと一致しません',
29
+ 'string.enum': '{{#label}}は次のいずれかである必要があります: {{#valids}}',
30
+
31
+ // Number
32
+ 'number.base': '{{#label}}は数値である必要があります',
33
+ 'number.min': '{{#label}}は{{#limit}}以上である必要があります',
34
+ 'number.max': '{{#label}}は{{#limit}}以下である必要があります',
35
+ 'number.integer': '{{#label}}は整数である必要があります',
36
+ 'number.positive': '{{#label}}は正の数である必要があります',
37
+ 'number.negative': '{{#label}}は負の数である必要があります',
17
38
 
18
- 'pattern.idCard': '無効なIDカード番号です',
39
+ // Boolean
40
+ 'boolean.base': '{{#label}}はブール値である必要があります',
19
41
 
20
- 'pattern.creditCard': '無効なクレジットカード番号です',
21
- 'pattern.creditCard.visa': '無効なVisaカード番号です',
22
- 'pattern.creditCard.mastercard': '無効なMastercard番号です',
23
- 'pattern.creditCard.amex': '無効なAmerican Expressカード番号です',
24
- 'pattern.creditCard.discover': '無効なDiscoverカード番号です',
25
- 'pattern.creditCard.jcb': '無効なJCBカード番号です',
26
- 'pattern.creditCard.unionpay': '無効な銀聯カード番号です',
42
+ // Object
43
+ 'object.base': '{{#label}}はオブジェクトである必要があります',
44
+ 'object.min': '{{#label}}は少なくとも{{#limit}}個のプロパティを持つ必要があります',
45
+ 'object.max': '{{#label}}は最大{{#limit}}個のプロパティを持つことができます',
46
+ 'object.unknown': '{{#label}}に未知のプロパティが含まれています: {{#key}}',
27
47
 
28
- 'pattern.licensePlate': '無効なナンバープレート番号です',
48
+ // Array
49
+ 'array.base': '{{#label}}は配列である必要があります',
50
+ 'array.min': '{{#label}}は少なくとも{{#limit}}個の要素を持つ必要があります',
51
+ 'array.max': '{{#label}}は最大{{#limit}}個の要素を持つことができます',
52
+ 'array.length': '{{#label}}は正確に{{#limit}}個の要素を持つ必要があります',
53
+ 'array.unique': '{{#label}}に重複する要素を含めることはできません',
29
54
 
30
- 'pattern.postalCode': '無効な郵便番号です',
55
+ // Date
56
+ 'date.base': '{{#label}}は有効な日付である必要があります',
57
+ 'date.min': '{{#label}}は{{#limit}}より前であってはなりません',
58
+ 'date.max': '{{#label}}は{{#limit}}より後であってはなりません',
31
59
 
32
- 'pattern.passport': '無効なパスポート番号です',
60
+ // Any
61
+ 'any.required': '{{#label}}は必須です',
62
+ 'any.invalid': '{{#label}}に無効な値が含まれています',
63
+ 'any.only': '{{#label}}は{{#valids}}と一致する必要があります',
64
+ 'any.unknown': 'フィールド{{#key}}は許可されていません',
33
65
 
34
- // New Types
35
- 'pattern.objectId': '無効なObjectIdです',
36
- 'pattern.hexColor': '無効な16進数カラーコードです',
37
- 'pattern.macAddress': '無効なMACアドレスです',
38
- 'pattern.cron': '無効なCron式です',
39
- 'pattern.slug': 'URLスラッグには、小文字、数字、ハイフンのみを含めることができます',
66
+ // Patterns (Legacy/Specific)
67
+ 'pattern.phone': '無効な電話番号',
68
+ 'pattern.phone.international': '無効な国際電話番号',
69
+ 'pattern.idCard': '無効なIDカード番号',
70
+ 'pattern.creditCard': '無効なクレジットカード番号',
71
+ 'pattern.creditCard.visa': '無効なVisaカード番号',
72
+ 'pattern.creditCard.mastercard': '無効なMastercardカード番号',
73
+ 'pattern.creditCard.amex': '無効なAmerican Expressカード番号',
74
+ 'pattern.creditCard.discover': '無効なDiscoverカード番号',
75
+ 'pattern.creditCard.jcb': '無効なJCBカード番号',
76
+ 'pattern.creditCard.unionpay': '無効なUnionPayカード番号',
77
+ 'pattern.licensePlate': '無効なナンバープレート',
78
+ 'pattern.postalCode': '無効な郵便番号',
79
+ 'pattern.passport': '無効なパスポート番号',
80
+ 'pattern.objectId': '無効なObjectId',
81
+ 'pattern.hexColor': '無効な16進カラー',
82
+ 'pattern.macAddress': '無効なMACアドレス',
83
+ 'pattern.cron': '無効なCron式',
84
+ 'pattern.slug': 'URLスラッグには小文字、数字、ハイフンのみを含めることができます',
85
+ // v1.0.2 新増
86
+ 'pattern.domain': '{{#label}}は有効なドメイン名である必要があります',
87
+ 'pattern.ip': '{{#label}}は有効なIPアドレスである必要があります',
88
+ 'pattern.base64': '{{#label}}は有効なBase64文字列である必要があります',
89
+ 'pattern.jwt': '{{#label}}は有効なJWTトークンである必要があります',
90
+ 'pattern.json': '{{#label}}は有効なJSON文字列である必要があります',
40
91
 
41
92
  // Username & Password
42
- 'pattern.username': 'ユーザー名は文字で始まり、文字、数字、アンダースコアのみを含める必要があります',
93
+ 'pattern.username': 'ユーザー名は文字で始まり、文字、数字、アンダースコアのみを含む必要があります',
43
94
  'pattern.password.weak': 'パスワードは少なくとも6文字である必要があります',
44
- 'pattern.password.medium': 'パスワードは少なくとも8文字で、文字と数字を含める必要があります',
45
- 'pattern.password.strong': 'パスワードは少なくとも8文字で、大文字、小文字、数字を含める必要があります',
46
- 'pattern.password.veryStrong': 'パスワードは少なくとも10文字で、大文字、小文字、数字、特殊文字を含める必要があります',
95
+ 'pattern.password.medium': 'パスワードは少なくとも8文字で、文字と数字を含む必要があります',
96
+ 'pattern.password.strong': 'パスワードは少なくとも8文字で、大文字、小文字、数字を含む必要があります',
97
+ 'pattern.password.veryStrong': 'パスワードは少なくとも10文字で、大文字、小文字、数字、特殊文字を含む必要があります',
47
98
 
48
99
  // Unknown error fallback
49
- 'UNKNOWN_ERROR': '未知の検証エラー',
100
+ 'UNKNOWN_ERROR': '不明な検証エラー',
50
101
 
51
102
  // Custom validation
52
103
  'CUSTOM_VALIDATION_FAILED': '検証に失敗しました',
53
- 'ASYNC_VALIDATION_NOT_SUPPORTED': '同期検証では非同期操作はサポートされていません',
54
- 'VALIDATE_MUST_BE_FUNCTION': 'validateは関数である必要があります',
55
-
56
- // Formats
57
- 'format.email': '無効なメールアドレスです',
58
- 'format.url': '無効なURLです',
59
- 'format.uuid': '無効なUUIDです',
60
- 'format.date': '無効な日付形式です (YYYY-MM-DD)',
61
- 'format.datetime': '無効な日時形式です (ISO 8601)',
62
- 'format.time': '無効な時間形式です (HH:mm:ss)',
63
- 'format.ipv4': '無効なIPv4アドレスです',
64
- 'format.ipv6': '無効なIPv6アドレスです'
104
+ 'ASYNC_VALIDATION_NOT_SUPPORTED': '同期validate()では非同期検証はサポートされていません',
105
+ 'VALIDATE_MUST_BE_FUNCTION': 'validateは関数である必要があります'
65
106
  };
66
107
 
@@ -21,11 +21,18 @@ module.exports = {
21
21
  'format.time': '{{#label}}必须是有效的时间格式 (HH:mm:ss)',
22
22
  'format.ipv4': '{{#label}}必须是有效的IPv4地址',
23
23
  'format.ipv6': '{{#label}}必须是有效的IPv6地址',
24
+ 'format.binary': '{{#label}}必须是有效的Base64编码',
24
25
 
25
26
  // String
26
27
  'string.hostname': '{{#label}}必须是有效的主机名',
27
28
  'string.pattern': '{{#label}}格式不符合要求',
28
29
  'string.enum': '{{#label}}必须是以下值之一: {{#valids}}',
30
+ // v1.0.2新增
31
+ 'string.length': '{{#label}}长度必须是{{#limit}}个字符',
32
+ 'string.alphanum': '{{#label}}只能包含字母和数字',
33
+ 'string.trim': '{{#label}}不能包含前后空格',
34
+ 'string.lowercase': '{{#label}}必须是小写',
35
+ 'string.uppercase': '{{#label}}必须是大写',
29
36
 
30
37
  // Number
31
38
  'number.base': '{{#label}}必须是数字类型',
@@ -34,6 +41,9 @@ module.exports = {
34
41
  'number.integer': '{{#label}}必须是整数',
35
42
  'number.positive': '{{#label}}必须是正数',
36
43
  'number.negative': '{{#label}}必须是负数',
44
+ // v1.0.2新增
45
+ 'number.precision': '{{#label}}小数位数不能超过{{#limit}}位',
46
+ 'number.port': '{{#label}}必须是有效的端口号(1-65535)',
37
47
 
38
48
  // Boolean
39
49
  'boolean.base': '{{#label}}必须是布尔类型',
@@ -43,6 +53,9 @@ module.exports = {
43
53
  'object.min': '{{#label}}至少需要{{#limit}}个属性',
44
54
  'object.max': '{{#label}}最多只能有{{#limit}}个属性',
45
55
  'object.unknown': '{{#label}}包含未知属性: {{#key}}',
56
+ // v1.0.2新增
57
+ 'object.missing': '{{#label}}缺少必需属性',
58
+ 'object.schema': '{{#label}}包含额外属性',
46
59
 
47
60
  // Array
48
61
  'array.base': '{{#label}}必须是数组类型',
@@ -50,11 +63,18 @@ module.exports = {
50
63
  'array.max': '{{#label}}最多只能有{{#limit}}个元素',
51
64
  'array.length': '{{#label}}必须有{{#limit}}个元素',
52
65
  'array.unique': '{{#label}}不能包含重复元素',
66
+ // v1.0.2新增
67
+ 'array.sparse': '{{#label}}不能是稀疏数组',
68
+ 'array.includesRequired': '{{#label}}必须包含指定元素',
53
69
 
54
70
  // Date
55
71
  'date.base': '{{#label}}必须是有效的日期',
56
72
  'date.min': '{{#label}}不能早于{{#limit}}',
57
73
  'date.max': '{{#label}}不能晚于{{#limit}}',
74
+ // v1.0.2新增
75
+ 'date.format': '{{#label}}日期格式不正确',
76
+ 'date.greater': '{{#label}}必须晚于{{#limit}}',
77
+ 'date.less': '{{#label}}必须早于{{#limit}}',
58
78
 
59
79
  // Any
60
80
  'any.required': '{{#label}}是必填项',
@@ -67,6 +87,12 @@ module.exports = {
67
87
  'pattern.phone.international': '请输入有效的国际手机号',
68
88
  'pattern.idCard': '请输入有效的身份证号码',
69
89
  'pattern.creditCard': '无效的信用卡号',
90
+ 'pattern.creditCard.visa': '无效的Visa卡号',
91
+ 'pattern.creditCard.mastercard': '无效的万事达卡号',
92
+ 'pattern.creditCard.amex': '无效的美国运通卡号',
93
+ 'pattern.creditCard.discover': '无效的Discover卡号',
94
+ 'pattern.creditCard.jcb': '无效的JCB卡号',
95
+ 'pattern.creditCard.unionpay': '无效的银联卡号',
70
96
  'pattern.licensePlate': '请输入有效的车牌号',
71
97
  'pattern.postalCode': '请输入有效的邮政编码',
72
98
  'pattern.passport': '请输入有效的护照号码',
@@ -75,6 +101,12 @@ module.exports = {
75
101
  'pattern.macAddress': '无效的 MAC 地址',
76
102
  'pattern.cron': '无效的 Cron 表达式',
77
103
  'pattern.slug': 'URL别名只能包含小写字母、数字和连字符',
104
+ // v1.0.2新增
105
+ 'pattern.domain': '{{#label}}必须是有效的域名',
106
+ 'pattern.ip': '{{#label}}必须是有效的IP地址',
107
+ 'pattern.base64': '{{#label}}必须是有效的Base64编码',
108
+ 'pattern.jwt': '{{#label}}必须是有效的JWT令牌',
109
+ 'pattern.json': '{{#label}}必须是有效的JSON字符串',
78
110
 
79
111
  // Username & Password
80
112
  'pattern.username': '用户名必须以字母开头,只能包含字母、数字和下划线',