-
Notifications
You must be signed in to change notification settings - Fork 39
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
Using a validator on multiple fields #61
Comments
Also the docs indicate I can specify a widget instead of a field. Two of these fields use the same widget, so I tried:
But this did not work either, and there is no error. The validator is not accessed. |
Would also like some feedback on this, would be nice to pass multiple fields to the validator..? |
I believe you have to use different discriminators to get this working. A workaround could be to provide a special interface for each field. Like this: (untested) class IAvailableAreas(zope.interface.Interface):
pass
class IAvailableIssueTypes(zope.interface.Interface):
pass
class ITracker(zope.interface.Interface):
available_areas = zope.schema.TextLine()
available_issue_types = zope.schema.TextLine()
zope.interface.alsoProvides(ITracker['available_areas'], IAvailableAreas)
zope.interface.alsoProvides(ITracker['available_issue_types'], IAlphaNumValue2)
validator.WidgetValidatorDiscriminators(
AlphaNumericValidator, field=IAvailableAreas)
validator.WidgetValidatorDiscriminators(
AlphaNumericValidator, field=IAvailableIssueTypes) Does this help? |
I've created a validator, but it will only work on one field at a time. Currently I have:
The validator will work on one of the fields, but ignores the other two. I've confirmed the validation works on each separately. How can I use the same validator on multiple fields?
The text was updated successfully, but these errors were encountered: