diff --git a/sources/29-web2py-english/07.markmin b/sources/29-web2py-english/07.markmin index 15e7d824..0083010f 100644 --- a/sources/29-web2py-english/07.markmin +++ b/sources/29-web2py-english/07.markmin @@ -2267,7 +2267,9 @@ On success, the ``__call__`` method reads a date string from the form and conver 01/01/2008 ``:code -When multiple validators are required (and stored in a list), they are executed in order and the output of one is passed as input to the next. The chain breaks when one of the validators fails. +#### Multiple Validators + +Normally, when multiple validators are required (and stored in a list), they are executed in order and the output of one is passed as input to the next. The chain breaks when one of the validators fails. Conversely, when we call the ``formatter`` method of a field, the formatters of the associated validators are also chained, but in reverse order. @@ -2275,6 +2277,25 @@ Conversely, when we call the ``formatter`` method of a field, the formatters of Notice that as alternative to custom validators, you can also use the ``onvalidate`` argument of ``form.accepts(...)``, ``form.process(...)`` and ``form.validate(...)``. ------ +As an alternative to the chained behavior described above, +the +``ANY_OF``:inxx validator can be used to combine a list of validators, +and to pass if **any** of the validators pass. +If none of the validators pass, +the error message returned will be that of the last validator in the +list. + +`` +>>> ANY_OF([IS_EMAIL(),IS_ALPHANUMERIC()])('a@b.co') +('a@b.co', None) +>>> ANY_OF([IS_EMAIL(),IS_ALPHANUMERIC()])('abco') +('abco', None) +>>> ANY_OF([IS_EMAIL(),IS_ALPHANUMERIC()])('@ab.co') +('@ab.co', 'enter only letters, numbers, and underscore') +>>> ANY_OF([IS_ALPHANUMERIC(),IS_EMAIL()])('@ab.co') +('@ab.co', 'enter a valid email address') +``:code + #### Validators with dependencies