Call
- Call(callable_fun: Any, rule: AbstractRule)
Validates the return of a callable for a given input.
Consider the following variable:
To validate every part of this URL we could use urlparse
function to break its parts:
This function returns an object ParseResult containing scheme, netloc, path and query.
We can validate them this way:
v.attribute('scheme', v.startsWith('http'))\
    .attribute('netloc', v.domain())\
    .attribute('path', v.stringType())\
    .attribute('query', v.notEmpty())\
    .validate(parts)
Using v.call() you can do this in a single chain:
v.call(
    urlparse,
    v.attribute('scheme', v.startsWith('http'))\
        .attribute('host',   v.domain())\
        .attribute('path',   v.stringType())\
        .attribute('query',  v.notEmpty())\
).validate(url)
Categorization
- Callables
- Nesting
Changelog
| Version | Description | 
|---|---|
| 1.0.0 | Created | 
See also: