Hello! For validation json
use library
https://github.com/justinrainbow/json-schema .
Made the following scheme:
{ "id": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#", "comment": "Schema for category validation during creation", "type": "object", "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[a-zA-Z0-9_-]+$" } }, "required": ["name"], "additionalProperties": false }
It works, but not as it should, namely: it does not allow whitespace characters in a validated string. such a regular expression with \t
or \s
included (example: "^[a-zA-Z0-9_-\s]+$"
) fails: phpunit returns JSON syntax is malformed
. If anyone in the know - please prompt.