Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can specify `minimum` and `maximum` property for these fields. So this schema

  {
    "$id": "https://example.com/test.schema.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Person",
    "type": "object",
    "properties": {
      "hp": {
        "type": "integer",
        "description": "HP",
        "minimum": 1,
        "maximum": 15
      }
    }
  }
is converted to this BNF-like representation:

  hp ::= ([1-9] | "1" [0-5]) space
  hp-kv ::= "\"hp\"" space ":" space hp
  root ::= "{" space  (hp-kv )? "}" space
  space ::= | " " | "\n"{1,2} [ \t]{0,20}


For anyone curious here is an interactive write up about this http://michaelgiba.com/grammar-based/index.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: