Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Problems - Bug or Seat to Keyboard Error? #194

Open
ghost opened this issue Sep 19, 2017 · 0 comments
Open

Validation Problems - Bug or Seat to Keyboard Error? #194

ghost opened this issue Sep 19, 2017 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented Sep 19, 2017

I am getting an unexpected error. I am expecting the wrong type for the value of meta.domain. I am passing an object when it should expect a string in the array. However, it appears not to be utilizing the $ref's at all. What am I doing wrong?

I am using

var allSchemasValid = validator.validateSchema(schemas); // schemas defined below but in right spot in my code.
var valid = validator.validate(data, schemas[5]);

As in the example however,

Data:
{meta: {domain: [{id: "circusliving.ca"}]}, name: {en: "ddd"}, description: {en: "dddx"}}

Data Validation Error:

{ "code": "INVALID_SCHEMA",
  "errors": [
    {
      "code": "OBJECT_ADDITIONAL_PROPERTIES",
      "params": [
        [
          "description",
          "name"
        ]
      ],
      "message": "Additional properties not allowed: description,name",
      "path": "#/",
      "schemaId": "role"
    }
  ]}

Schema Array:

[{
    "_id" : ObjectId("59bbe6492b2a11bba572f6ba"),
    "id" : "role",
    "schema" : "role",
    "collection" : "roles",
    "title" : "Roles",
    "type" : "object",
    "properties" : {
        "_id" : {
            "type" : "string"
        },
        "meta" : {
            "type" : "object",
            "$ref" : "meta"
        },
        "allOf" : [ 
            {
                "$ref" : "thing"
            }, 
            {
                "$ref" : "attachment"
            }, 
            {
                "$ref" : "label"
            }
        ],
        "startDate" : {
            "type" : "string"
        },
        "endDate" : {
            "type" : "string"
        },
        "roleName" : {
            "type" : "string"
        }
    },
    "security" : {
        "list" : [ 
            "administrator", 
            "admin", 
            "root"
        ],
        "read" : [ 
            "administrator", 
            "admin", 
            "root"
        ],
        "create" : [ 
            "administrator", 
            "admin", 
            "root"
        ],
        "update" : [ 
            "administrator", 
            "admin", 
            "root"
        ],
        "delete" : [ 
            "administrator", 
            "admin", 
            "root"
        ],
        "schema" : [ 
            "everyone"
        ]
    },
    "additionalProperties" : false,
    "versioning" : true
},
    {
    "_id" : "59bd21fe2b2a11bba57506d9",
    "id" : "meta",
    "schema" : "meta",
    "title" : "meta data",
    "type" : "object",
    "properties" : {
        "version" : {
            "type" : "integer"
        },
        "state" : {
            "type" : "string"
        },
        "createdBy" : {
            "type" : "string"
        },
        "createdOn" : {
            "type" : "string"
        },
        "modifiedBy" : {
            "type" : "string"
        },
        "modifiedOn" : {
            "type" : "string"
        },
        "contributors" : {
            "type" : "array",
            "items" : [
                {
                    "type" : "string"
                }
            ]
        },
        "domain" : {
            "type" : "array",
            "items" : [
                {
                    "type" : "string",
                    "format" : "hostname"
                }
            ]
        }
    },
    "isDefinition" : true
},
{
    "_id" : ObjectId("59bd23b72b2a11bba5750a12"),
    "id" : "thing",
    "schema" : "thing",
    "title" : "thing the base for all schemas",
    "type" : "object",
    "properties" : {
        "id" : {
            "type" : "object",
            "$ref" : "lString"
        },
        "title" : {
            "type" : "object",
            "$ref" : "lString"
        },
        "identifier" : {
            "type" : "string",
            "format" : "uri"
        },
        "name" : {
            "type" : "object",
            "$ref" : "lString"
        },
        "alternateName" : {
            "type" : "object",
            "$ref" : "lString"
        },
        "alternateType" : {
            "type" : "string",
            "format" : "strict-uri"
        },
        "description" : {
            "type" : "object",
            "$ref" : "lString"
        },
        "disambiguatingDescription" : {
            "type" : "object",
            "$ref" : "lString"
        },
        "image" : {
            "type" : "string",
            "format" : "strict-uri"
        },
        "sameAs" : {
            "type" : "string",
            "format" : "strict-uri"
        }
    },
    "isDefinition" : true
},
{
    "_id" : ObjectId("59bd26ea2b2a11bba575100c"),
    "id" : "attachment",
    "schema" : "attachment",
    "title" : "Attachments",
    "type" : "object",
    "properties" : {
        "attachement" : {
            "type" : "array",
            "name" : "attachements",
            "items" : [ 
                {
                    "type" : "string"
                }
            ]
        }
    },
    "isDefinition" : true
},
{
    "_id" : ObjectId("59bd27392b2a11bba57510a0"),
    "id" : "label",
    "schema" : "label",
    "title" : "Labels",
    "type" : "object",
    "properties" : {
        "label" : {
            "type" : "array",
            "name" : "labels",
            "items" : [ 
                {
                    "type" : "string"
                }
            ]
        }
    },
    "isDefinition" : true
},
{
    "_id" : ObjectId("59be67f62b2a11bba577452d"),
    "id" : "lString",
    "schema" : "lString",
    "title" : "Language String",
    "type" : "object",
    "properties" : {
        "ar" : {
            "type" : "string"
        },
        "zh" : {
            "type" : "string"
        },
        "en" : {
            "type" : "string"
        },
        "fr" : {
            "type" : "string"
        },
        "ru" : {
            "type" : "string"
        },
        "es" : {
            "type" : "string"
        }
    },
    "isDefinition" : true
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant