Validate that the parsed result has expected structure
The parsed data to validate
Array of required field names
Result containing validated data, or error if structure is invalid
const result = validateJSONStructure(data, ['name', 'version'])if (result.ok) { console.log('Valid structure:', result.value)} else { console.error('Missing fields:', result.error.context.missingFields)} Copy
const result = validateJSONStructure(data, ['name', 'version'])if (result.ok) { console.log('Valid structure:', result.value)} else { console.error('Missing fields:', result.error.context.missingFields)}
Validate that the parsed result has expected structure