1.0.1 • Published 7 years ago
walli-decorator v1.0.1
walli-decorator
The semantic walli definition by decorator.
API
walliDecorator
The decorator about walli.
Parameters
walliInstance
Examples
import walliDecorator, { check } from 'walli-decorator'
import * as w from 'walli'
class A {
@walliDecorator(w.string)
abc = 123
}
check(new A()) // { abc: 'expected type: string, actual type: number.' }
// The usage of options.recursive
class B {
a = new A()
}
check(new B()) // null
check(new B(), { recursive: true }) // { a: { abc: 'expected type: string, actual type: number.' } }check
Check the target
Parameters
target{any}optionsObject {{}}options.abortWhenFail{boolean} - Whether aborting the check flow when illegal value has been found. (optional, defaultfalse)options.excludes{string[]} - The excluding field name list. (optional, default[])options.includes{string[]} - The including field name list. (optional, default[])options.order{string[]} - The order of field name list. (optional, default[])options.ignoreValIsUndefinedWhether ignoring the check flow when value is undefined. (optional, defaulttrue)options.ignoreNotHasValWhether ignoring the check flow when the target has not value. (optional, defaulttrue)options.recursiveWhether checking the target recursively. (optional, defaultfalse)options.returnWalliResultWhether returning walli check's result. (optional, defaultfalse)
Returns (null | object)