Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json Schema Example for patternProperties

can anyone give me an example of how to use the patternProperties item for json schema?

"Example" :
  "type" : "object",
  "patternProperties" :
  {
     <how do I use this>
  }

What I want to do in the json file is allow any subitem of "Example" that is starting with A e.g.:

{
  "Example" : 
  {
    "Aaa" : { ...}
  }
}

is patternProperties the right choice for this?

like image 356
Stephan Avatar asked Feb 03 '23 07:02

Stephan


1 Answers

{
  type: 'object',
  patternProperties: {
    '^A': {
      type: 'string',
      ...
    }
  }
}
like image 184
Baggz Avatar answered Feb 05 '23 06:02

Baggz