G10 : dist/ rebâti (retour du checkpoint : n° 1 à 11) ; npm test 182 sur 182
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vendored
+4
-1
@@ -1,7 +1,7 @@
|
||||
// valider.ts — validation structurelle d'un JSON de données contre le schéma
|
||||
// de sa table (schemas/<table>.schema.json, incarné par schemas.ts). Sans
|
||||
// dépendance, sans I/O. Ce n'est pas un validateur JSON Schema complet : type,
|
||||
// required, properties, items, enum, minItems.
|
||||
// required, properties, items, enum, minItems, pattern.
|
||||
import { SCHEMAS } from './schemas.js';
|
||||
const MAX_ERREURS = 20;
|
||||
function typeDe(v) {
|
||||
@@ -32,6 +32,9 @@ function verifie(schema, valeur, chemin, erreurs) {
|
||||
if (schema.enum && !schema.enum.includes(valeur)) {
|
||||
erreurs.push(`${chemin} : valeur « ${String(valeur)} » hors de ${schema.enum.map(String).join(', ')}`);
|
||||
}
|
||||
if (schema.pattern != null && reel === 'string' && !new RegExp(schema.pattern).test(valeur)) {
|
||||
erreurs.push(`${chemin} : « ${String(valeur)} » ne suit pas le motif ${schema.pattern}`);
|
||||
}
|
||||
if (reel === 'array') {
|
||||
const tableau = valeur;
|
||||
if (schema.minItems != null && tableau.length < schema.minItems) {
|
||||
|
||||
Reference in New Issue
Block a user