I'm using Everit to check some json in a java application, and I have this issue both in the application during the check and in other online validators.
The json request contains the string abcdef&© with one single character which doesn't match © the regex. The regex should be able to match any alphanumeric string and the ampersand.
{"type":"sector","attributes":{"name":"abcdef&©"}}
The regex is defined in the json schema under pattern. In this case we're using the pattern: [a-zA-Z0-9\u0026]+ (unicode character is for ampersand) to validate the above JSON.
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://example.com/example.json",
  "type": "object",
  "definitions": {},
  "properties": {
    "attributes": {
      "properties": {
        "name": {
          "pattern": "[a-zA-Z0-9\u0026]+",
          "id": "/data/properties/attributes/name",
          "type": "string"
        }
      }
    },
    "objecttype": {
      "pattern": "sector",
      "id": "/data/properties/type",
      "type": "string"
    }
  },
  "required": [
    "type",
    "attributes"
  ]
}
Interestingly if I additionally use the copyright symbol the regex validates this as a success and if I attempt to validate it on its own, the regex validates this as a failure. How can I ensure that the use of any character other than those I've specified results in a failure?
- SUCCESS    {"type":"sector","attributes":{"name":"abcdef&©"}}
- FAILURE    {"type":"sector","attributes":{"name":"©"}}
