Skip to content

Patterns don't use / #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Patterns don't use / #5

wants to merge 1 commit into from

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