Skip to content

Custom FormatChecker #674

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

Closed
Sharealikelicence opened this issue Apr 3, 2020 · 2 comments
Closed

Custom FormatChecker #674

Sharealikelicence opened this issue Apr 3, 2020 · 2 comments

Comments

@Sharealikelicence
Copy link

Hi,
Just wondering if there is a way to extend the FormatChecker that is passed to the validator? I can't seem to find anything in the documentation.
Basically, I am trying to check if a string value is a valid timezone. I'm using pytz for the timezone side. But, I need to check the provided json string property is contained within that list.
The only other way I can think of is to extract the list as an enum field in the schema. But, it's a huge list and seems a pretty clunky way of doing it.
Thanks in advance.

@Julian
Copy link
Member

Julian commented Apr 4, 2020

Hi. Are you looking for FormatChecker.checks?

@Julian Julian closed this as completed Apr 7, 2020
@Sharealikelicence
Copy link
Author

I ended up finding it. But, I used cls_checks instead:

timezone_checker = FormatChecker.cls_checks(format='timezone', raises=ValueError)
timezone_checker(check_timezone)

Julian added a commit that referenced this issue May 30, 2023
b069ac352 Add tests for non-relative URI anchor referencing
7950d9e05 Merge pull request #674 from jmigual/feature/alah
e6a089ae9 Changed description about `main` branch
b3c074773 Add comment about live at head philosophy
ab4bd012f Merge pull request #671 from marksparkza/schemaloc-fragment
e7aba0972 Include fragment in schemaLocation

git-subtree-dir: json
git-subtree-split: b069ac352c3dc1fae71f6f177dafe97001c97920
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

2 participants