shuttle-hq / synth

The Declarative Data Generator
https://www.getsynth.com/
Apache License 2.0
1.39k stars 109 forks source link

Improve error messages on arrays with negative length #186

Closed llogiq closed 2 years ago

llogiq commented 3 years ago

Describe the bug The error message on specifying a negative-length array, while not wrong, could be more helpful (and suggest specifying a positive length instead)

To Reproduce Steps to reproduce the behavior:

  1. Schema (if applicable)
    {
    "type": "array",
    "length": -1,
    "content": {
        "type": "object"
    }
    }
  2. See error
    BadRequest: could not convert from value 'i64(-1)': Type { expected: "U32", got: "i64(-1)" }

Expected behavior

Something like "you specified an array of negative length (-1). Arrays can only have length 0 or higher. Did you mean length 1?"

Environment (please complete the following information):