Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Improve error messages of JSON validator #31

Closed
alex3683 opened this issue Jul 4, 2014 · 2 comments
Closed

Improve error messages of JSON validator #31

alex3683 opened this issue Jul 4, 2014 · 2 comments

Comments

@alex3683
Copy link
Member

alex3683 commented Jul 4, 2014

Currently the JSON validator only prints the name of the erroneous attribute when the validation of a property by schema fails. In many cases this is not helpful at all, if for example a widget has many features, each with e.g. a property resource and the error message only says that the configuration for resource is insufficient. The expected output is the full path to the property, e.g. someFeature.resource.

@alex3683
Copy link
Member Author

alex3683 commented Jul 9, 2014

The JSON validator will still expose the same api but use jjv (https://github.com/acornejo/jjv) as actual validator and jjve (https://github.com/silas/jjve) as message generator for the jjv output.

@alex3683
Copy link
Member Author

Implemented on master, targeted version v0.11.0.

Upgrade Information

The self-written JSON validator was replaced by jjv as actual validator and jjve as message generator for the jjv output. The api exposed by the LaxarJS validator didn't change. The JSON instantiator was removed in favor of jjv, which also has the ability to apply default values from the schema if necessary.

Mandatory changes

The usage of two new external libraries induces a mandatory addition in the configuration for RequireJS in an application (require_config.js in the application template). The following two path definitions need to be added to the paths mapping:

jjv: '../bower_components/jjv/lib/jjv',
jjve: '../bower_components/jjve/jjve',

Optional upgrade

A minimal v3 to v4 schema transformation of the required property takes place, if a schema is given without schema version or if the schema version is not v4. As this may not be sufficient where more sophisticated schemata are needed, it is advised to define new schemata as v4 and transform older schemata to v4. As soon as the root schema defines the $schema property as http://json-schema.org/draft-04/schema#, the transformation is disabled and a valid v4 schema is assumed.

Example of a v4 schema:

{
   "$schema": "http://json-schema.org/draft-04/schema#",
   "type": "object",
   "required": [ "myMandatoryProperty" ],
   "properties": {
      "myMandatoryProperty": {
         "type": "string"
      }
   }
}

The v3 version would have been:

{
   "type": "object",
   "properties": {
      "myMandatoryProperty": {
         "type": "string",
         "required": true
      }
   }
}

@alex3683 alex3683 removed their assignment Jul 14, 2014
jpommerening added a commit to LaxarJS/grunt-laxar that referenced this issue Aug 6, 2014
jpommerening added a commit to jpommerening/grunt-laxar that referenced this issue Aug 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant