Skip to content

Cannot set the error for a type of array #38

@shuowpro

Description

@shuowpro

Problem:

I tried with a schema like this

var schema = {
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "foo": { "type": "string" },
      "bar": { "type": "number", "maximum": 3 }
    }
  }
};

This is an array schema, I cannot get the error when I want to valid the properties inside the object of the array such as foo or bar.
I don't know whether that is a bug. I try to validate that with ajv, and the ajv reported 2 errors with dataPath: [0].foo and [0].bar, the first character of the dataPath is not ., so that I think that might the reason why the buildSyncValidate will not transform the dataPath into the format like /0/foo, so that I cannot validate the field in a object in the array.

I think the if statement of detect whether the first character of dataPath is . or not is redundant. This will be repaired by remove that if statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions