3

I'm trying to use jsonschema for a schema which uses "pattern". However in this application, the "pattern" needs to be able to match unicode characters, which is not support by python's builtin "re" module.

for example

import jsonschema
import regex

schema = {
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "pattern": "[\p{L}]+"
        },
    },
}

if (regex.compile(schema["properties"]["name"]["pattern"]).search("ᚠᛇᚻ")):
    print("It matched")

jsonschema.validate(instance={"name" : "ᚠᛇᚻ"}, schema=schema)

If I run this, the "regex" search works, but the schema validation fails with...

jsonschema.exceptions.SchemaError: '[\\p{L}]+' is not a 'regex'

So what I'm wondering is if there is some way to get jsonschema.validate to ignore the normal "pattern" validation and instead check the pattern with the "regex" module. I'm very new to jsonschema, so I don't quite know where to start.

0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.