Ticket #14203 (new Bug)
at_validate_field
Reported by: | frisi | Owned by: | davisagli |
---|---|---|---|
Priority: | minor | Milestone: | 4.x |
Component: | Archetypes | Version: | 4.3 |
Keywords: | validation | Cc: |
Description
custom validators do never get called for inline validation (at_validate_input)
in short:
inline-validation passes different form data than widgets get on archetypes form submit. isEmpty returns True instead of False validation chain stops processing the other validators since it thinks the field is empty
in more detail:
field definition::
'validators' : ((integerValidator, V_REQUIRED),),
inline validation only passes form data for the current field
eg:
{'value': ' 34532', 'uid': '16a42167327e4db4b4c4be93c6d29f84', 'fname': 'runningCosts'}
the isEmtpyNoError validator calls the widgets process_form method https://github.com/plone/Products.validation/blob/master/Products/validation/validators/EmptyValidator.py#L32
which in turn requires the value to be supplied under a key matching fieldname https://github.com/plone/Products.Archetypes/blob/1.10.1/Products/Archetypes/Widget.py#L127
eg
{'runningCosts': ' 34532', 'otherField': True}
this makes the isEmpty validator return True, although the user provided an input for this field.
archetypes automatically adds an isEmptyNoError for non required fields in case there are other validators in the chain
https://github.com/plone/Products.Archetypes/blob/1.10.1/Products/Archetypes/Field.py#L303
our validation chain automatically became
(('isEmptyNoError', V_SUFFICIENT), ('integerValidator', V_REQUIRED))
since validation chain stops after a sufficient validator is happy, our custom validator does not get called https://github.com/plone/Products.validation/blob/master/Products/validation/chain.py#L139
using plone4.3.3