parseSchema method
Implementation
Schema parseSchema(Object json, {String path = 'schema'}) {
try {
_validateJsonValue(json, path);
_validateSchemaStructure(json, path);
final normalized = _normalize(json);
final compilation = _compile(normalized, path: path);
return Schema._(_deepCopy(json)!, normalized, compilation.resources, {
null: compilation.validator,
}, this);
} on FormatException catch (error) {
if (error.message.toString().startsWith(path)) rethrow;
throw FormatException('$path: ${error.message}');
} on json_schema.SchemaException catch (error) {
final location = error.schemaPath.isEmpty ? '' : '#${error.schemaPath}';
throw FormatException('$path$location: ${error.message}');
} on json_schema.ReferenceException catch (error) {
throw FormatException('$path: ${error.message} (${error.reference})');
} on Object catch (error) {
throw FormatException('$path: invalid JSON Schema: $error');
}
}