I am currently having a JSON schema in my code
{
'type' => 'object', 'required' => true, 'additionalProperties' => false,
'properties' => {
'variables' => {
'type' => 'array', 'required' => true,
'items' => {
'type' => 'object', 'required' => true, 'additionalProperties' => false,
'properties' => {
'variable' => { 'type' => 'string', 'required' => true },
'value' => { 'required' => true }
}
}
}
}
}
I am trying to put some extra validations here on value field. E.g. In case on String length should not be more than 64 chars , and in case of Integer value should be in Integer limit. how should I go about defining this schema.
For positive integer less or equal to 1024:
"type": "integer",
"minimum": 0,
"maximum": 1024
For string to be not empty and not longer than 64 symbols:
"type": "string",
"pattern": "^.{1,64}$"
There are good explanations of all the guards at official site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With