Skip to content

Commit

Permalink
fix(content_serdes): don't use uriVariables for validating
Browse files Browse the repository at this point in the history
This currently a workaround that requires a proper reimplementation.
  • Loading branch information
JKRhb committed Dec 19, 2023
1 parent d3d2919 commit 207b362
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/src/core/content_serdes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ class ContentSerdes {
}

void _validateValue(Object? value, DataSchema? dataSchema) {
final dataSchemaJson = dataSchema?.rawJson;
if (dataSchemaJson == null) {
// TODO(JKRhb): The process of validating values according to a dataschema
// needs to be reworked.
const filteredKeys = ['uriVariables'];

final filteredDataSchemaJson = dataSchema?.rawJson?.entries
.where((element) => !filteredKeys.contains(element.key));
if (filteredDataSchemaJson == null) {
return;
}
final schema =
JsonSchema.create(dataSchemaJson, schemaVersion: SchemaVersion.draft7);
final schema = JsonSchema.create(
Map.fromEntries(filteredDataSchemaJson),
schemaVersion: SchemaVersion.draft7,
);
if (!schema.validate(value).isValid) {
throw ContentSerdesException('JSON Schema validation failed.');
}
Expand Down

0 comments on commit 207b362

Please sign in to comment.