forked from collective/collective.volto.formsupport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul how we're passing settings back and forth
- Loading branch information
1 parent
6606bc1
commit 731d331
Showing
9 changed files
with
126 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from Products.validation import validation | ||
|
||
|
||
class ValidationDefinition: | ||
def __init__(self, validator): | ||
self._name = validator.name | ||
self._settings = vars(validator) | ||
|
||
def __call__(self, value, **kwargs): | ||
"""Allow using the class directly as a validator""" | ||
return self.validate(value, **kwargs) | ||
|
||
@property | ||
def settings(self): | ||
return self._settings | ||
|
||
@settings.setter | ||
def settings(self, value): | ||
self._value = value | ||
|
||
def validate(self, value, **kwargs): | ||
if value is None: | ||
# Let the system for required take care of None values | ||
return | ||
res = validation(self._name, value, **kwargs) | ||
if res != 1: | ||
return res |
10 changes: 10 additions & 0 deletions
10
src/collective/volto/formsupport/validation/validation.zcml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<!-- All validations vocabulary --> | ||
<utility | ||
name="collective.volto.formsupport.Validators" | ||
component=".validation.ValidatorsVocabularyFactory" | ||
/> | ||
|
||
|
||
</configure> |