Skip to content

No validation of member values in accordance with their data type #309

@jason-fox

Description

@jason-fox

Specification states:

5.5.4 JSON-LD validation
All the operations that take a JSON-LD document as input shall process such JSON-LD
document as follows:
• If the request payload body is not a valid JSON document then an error of type InvalidRequest shall be raised.
• If the data included by the JSON-LD document is not syntactically correct, according to the @context or the API Data type definitions, then an error of type BadRequestData shall be raised. For the avoidance of doubt, this includes validation of member values in accordance with their data type, for instance DateTime, and validation of each Relationship's target object which shall be a syntactically valid URI.

The following is therefore invalid since the datetime is not a date - but parses correctly.

curl -X POST \
  'http://localhost:1026/ngsi-ld/v1/entities/' \
  -H 'Content-Type: application/ld+json' \
  -d '{
    "id": "urn:ngsi-ld:Building:something",
    "type": "Building",
    "sillyDate": {
    "type": "Property",
    "value": {
        "@type": "DateTime",
        "@value": "" 
    }
  },
    "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld"
}'

it should return BadRequestData

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions