Skip to content

Conversation

@fidian
Copy link

@fidian fidian commented Nov 8, 2012

According to the examples I've seen on mailing lists, JSON Schema's patterns look like this:

{
    "type": "string",
    "pattern": "^[a-zA-Z]*$"
}

Your tests assume they start and end with a slash.

@fidian
Copy link
Author

fidian commented Dec 20, 2012

Is there any update on this pull request? I see that the other JSON schema project asked you to join their forces (and that's awesome), but I'd still love for this library to get this bug fixed.

@bmoelk
Copy link

bmoelk commented Oct 23, 2015

+1 on the need

Even if there is a good solution to this problem, I don't know the odds of it getting merged in after 9 months. I'll try to stay hopeful though.

Still hopeful after 2 years 3 months?

@bmoelk
Copy link

bmoelk commented Oct 23, 2015

Backticks don't have any special meaning within the regex AND can be used as delimiters (if escaped), therefore I believe this code should work:

if (!preg_match('' . str_replace('', '', $schema->pattern) . '', $entity)) {

Forked/fixed/tested here: https://github.com/shrm-org/php-json-schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants