Skip to content

Conversation

@pawelkocot
Copy link

@pawelkocot pawelkocot commented Sep 5, 2016

when you have fields in schema added after field with "each" validator, then errors from "each" validator are assigned to the last field's name from schema.

example:

var schema = new Schemator({
  books: {
    type : 'array',
    each : new Schemator({
      author : {
        type : 'string',
      }
    })
  },
  name : {
    type: 'string'
  }
});

var data = {
  books: [
    {}
  ],
  name : 'name'
};

result:
[ [ [ 'name', 0, 'author' ], 'type', 'author field didn't mach the type string.' ] ]

expected result:
[ [ [ 'books', 0, 'author' ], 'type', 'author field didn't mach the type string.' ] ]

when you have fields in schema after field with "each" validator, then errors are assigned to the last field name.

example:
var schema = new Schemator({
  books: {
    type : 'array',
    each : new Schemator({
      author : {
        type : 'string',
      }
    })
  },
  name : {
    type: 'string'
  }
});

var data = {
  books: [
    {}
  ],
  name : 'name'
};

result:
[ [ [ 'name', 0, 'author' ], 'type', 'author field didn\'t mach the type string.' ] ]

expected result:
[ [ [ 'books', 0, 'author' ], 'type', 'author field didn\'t mach the type string.' ] ]
@pawelkocot
Copy link
Author

@alanhoff please check....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant