1. Ludia
  2. Untitled project
  3. onctuous

Commits

Jean-Tiare Le Bigot  committed 13bb1e1

add precision on validator conventions in documentation

  • Participants
  • Parent commits 1acd2e9
  • Branches default

Comments (0)

Files changed (1)

File docs/pages/extending.rst

View file
 to add your custom validator into ``ddmock.validators`` module. Otherwise, put it
 wherever you want, there are no restrictions.
 
-Technically speaking, any callable can be a validator.
+By convention, validators are:
+
+ - Callable
+ - Returns the validated value on success, even unmodified. This ensures chainability
+ - Raises ``Invalid`` on failure
 
 All validators will look like this:
 
 ::
 
     # Parent function: loads the parameters
-    def ValidatorName(param1, param2, ..., msg=None):
+    def ValidatorName(param1, param2, msg=None):
         # this 'inner' function does the real job and is called by ``Onctuous``
         def f(v):
             if some condition: