Skip to content

Non standard and unserialisable data structure returned from nested schemas #20

@eliothowes

Description

@eliothowes

See https://runkit.com/eliothowes1090/hannibal-error-example for example of issue.

Given the following schema:

{
    type: 'object',
    schema: {
        foo: {
            type: 'array',
            validators: {
                max: 2
            },
            schema: {
                type: 'string',
                validators: {
                    enum: [
                        'fish', 
                        'chips'
                    ]
                }
            }
        }
    }
}

And the following data structure:

{
    foo: [
      '',
      'not fish',
      'not chips'
    ]
}

The following error object is returned:

foo: [
  {enum: "string:  is not one of: fish, chips"},
  {enum: "string: not chips is not one of: fish, chips"},
  {enum: "string: not chips is not one of: fish, chips"},
  max: "array is too long, requires: 2 items and was: 3"
]

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