File tree Expand file tree Collapse file tree 2 files changed +19
-23
lines changed Expand file tree Collapse file tree 2 files changed +19
-23
lines changed Original file line number Diff line number Diff line change @@ -140,12 +140,19 @@ class ContentSerdes {
140140 }
141141
142142 void _validateValue (Object ? value, DataSchema ? dataSchema) {
143- final dataSchemaJson = dataSchema? .rawJson;
144- if (dataSchemaJson == null ) {
143+ // TODO(JKRhb): The process of validating values according to a dataschema
144+ // needs to be reworked.
145+ const filteredKeys = ['uriVariables' ];
146+
147+ final filteredDataSchemaJson = dataSchema? .rawJson? .entries
148+ .where ((element) => ! filteredKeys.contains (element.key));
149+ if (filteredDataSchemaJson == null ) {
145150 return ;
146151 }
147- final schema =
148- JsonSchema .create (dataSchemaJson, schemaVersion: SchemaVersion .draft7);
152+ final schema = JsonSchema .create (
153+ Map .fromEntries (filteredDataSchemaJson),
154+ schemaVersion: SchemaVersion .draft7,
155+ );
149156 if (! schema.validate (value).isValid) {
150157 throw ContentSerdesException ('JSON Schema validation failed.' );
151158 }
Original file line number Diff line number Diff line change @@ -318,34 +318,23 @@ class Form {
318318 return null ;
319319 }
320320
321- if (affordanceUriVariables.isEmpty) {
322- throw UriVariableException (
323- 'The Form href $href contains URI '
324- 'variables but the TD does not provide a uriVariables definition.' ,
321+ if (uriVariables != null ) {
322+ // Perform additional validation
323+ _validateUriVariables (
324+ hrefUriVariables,
325+ affordanceUriVariables,
326+ uriVariables,
325327 );
326328 }
327329
328- if (uriVariables == null ) {
329- throw ValidationException (
330- 'The Form href $href contains URI variables '
331- 'but no values were provided as InteractionOptions.' ,
332- );
333- }
334-
335- // Perform additional validation
336- _validateUriVariables (
337- hrefUriVariables,
338- affordanceUriVariables,
339- uriVariables,
340- );
341-
342330 // As "{" and "}" are "percent encoded" due to Uri.parse(), we need to
343331 // revert the encoding first before we can insert the values.
344332 final decodedHref = Uri .decodeFull (href.toString ());
345333
346334 // Everything should be okay at this point, we can simply insert the values
347335 // and return the result.
348- final newHref = Uri .parse (UriTemplate (decodedHref).expand (uriVariables));
336+ final newHref =
337+ Uri .parse (UriTemplate (decodedHref).expand (uriVariables ?? {}));
349338 return _copy (newHref);
350339 }
351340}
You can’t perform that action at this time.
0 commit comments