Skip to content
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

FormatChecker not working on 'email' #336

Closed
pll opened this issue May 24, 2017 · 4 comments
Closed

FormatChecker not working on 'email' #336

pll opened this issue May 24, 2017 · 4 comments

Comments

@pll
Copy link

pll commented May 24, 2017

I'm sure I'm likely doing something wrong.

This code works fine:

jsonschema.validate("pll@foo.com",
                    { "format" : "email"},
                    format_checker=jsonschema.FormatChecker())

But when I define a schema like this:

{
   "type" : "object",
    "tags" : {
	"email" : {
	    "type" : "string",
	    "format" : "email"
       }
    }
}

and load it in from a file and use it to validate a file like this:

{
    "tags" : {
	"email": "noreply",
    }
}

using this code:

 jsonschema.validate(config,
                                    schema,
                                    format_checker=jsonschema.FormatChecker())

It passes. Despite the tags["email"] value not being a valid email format.

What am I doing wrong?

Thanks!

@Julian
Copy link
Member

Julian commented May 24, 2017 via email

@pll
Copy link
Author

pll commented May 25, 2017

Doh! I knew I was doing something wrong :)

Thanks. Should a format of email pass on a string like "@" ? Or am I doing something else wrong now :)

@mxmader
Copy link

mxmader commented Jun 3, 2017

@pll have a look at jsonschema._format which simply looks for the presence of the @ character in the string when validating the email format. If you want something fancier like validation against the RFC822 address specification, I suggest you use a custom format with one or more regular expressions or submit a PR to enhance the built-in functionality of jsonschema._format. Acknowledging that, this issue could close.

@pll
Copy link
Author

pll commented Jun 3, 2017

Thanks!

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

No branches or pull requests

3 participants