The semantic walli definition by decorator.
The decorator about walli.
walliInstance
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 the target
target
{any}options
Object {{}}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.ignoreValIsUndefined
Whether ignoring the check flow when value is undefined. (optional, defaulttrue
)options.ignoreNotHasVal
Whether ignoring the check flow when the target has not value. (optional, defaulttrue
)options.recursive
Whether checking the target recursively. (optional, defaultfalse
)options.returnWalliResult
Whether returning walli check's result. (optional, defaultfalse
)
Returns (null | object)