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

Allow IValidator to override existing validators #3865

Merged
merged 3 commits into from Nov 10, 2017

Conversation

wardi
Copy link
Contributor

@wardi wardi commented Oct 11, 2017

There are cases where overriding a built-in or plugin-defined validator is much simpler than redefining a one or more whole schemas.

This change allows IValidator plugins to override existing validators, following the established "first plugin wins" pattern. Validators are usually simple functions and they can be created with a number of different function signatures, so we don't attempt to "chain" validators like we do when overriding action methods. one validator wins and is the only one that will be called.

Current behaviour is to raise a NameConflict error, this will no longer happen.

The core schema.py imports validator functions directly, should we change schema.py to call get_validator() as part of the same PR for consistency, or make this only affect schemas defined in plugins or with ckanext-scheming?

@wardi wardi removed the WIP label Oct 24, 2017
@amercader amercader self-assigned this Oct 24, 2017
@amercader amercader merged commit 6edfaa3 into master Nov 10, 2017
@amercader amercader deleted the 3865-validator-override branch November 10, 2017 14:01
@wardi
Copy link
Contributor Author

wardi commented Nov 10, 2017

@amercader thanks!

wardi added a commit to wardi/ckan that referenced this pull request Feb 9, 2018
wardi added a commit to wardi/ckan that referenced this pull request Feb 9, 2018
jguo144 pushed a commit to OpenGov-OpenData/ckan that referenced this pull request Feb 21, 2018
jguo144 pushed a commit to OpenGov-OpenData/ckan that referenced this pull request Feb 21, 2018
jguo144 pushed a commit to OpenGov-OpenData/ckan that referenced this pull request Jul 5, 2018
jguo144 pushed a commit to OpenGov-OpenData/ckan that referenced this pull request Jul 5, 2018
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.

None yet

2 participants