Define a class member. It is necessary and should be put at the first site if you want to use some validation decorators
- options [
object
]: Options about the behavior of get and set in class member. There are- checkDefault [
bool
]: If true, the default value would be validated. Default isfalse
. - silence [
bool
]: If true, the type validation would be set as silence mode (without log error). Default isfalse
.
- checkDefault [
- model [
component
]: The React component.
- type [
prop-types
]: The type of the class member. model-decorator use props-types to define the type. - options [
object
]:- errorMessage [
string
]: The error message. Default isundefined
.
- errorMessage [
- bound [
array
]: The boundary of string length. For example: [0, 10] where 0 is lower bound and 10 is upper bound. - options [
object
]:- errorMessage [
string
]: The error message. Default isundefined
. - mode [
string
]: The mode of bound. There are eight modes.
[]
: lower bound <= value <= upper bound(]
: lower bound < value <= upper bound[)
: lower bound <= value < upper bound()
: lower bound < value < upper bound][
: lower bound >= value || upper bound <= value](
: lower bound >= value || upper bound < value)[
: lower bound > value || upper bound <= value)(
: lower bound > value || upper bound < value
- errorMessage [
- options [
object
]:- errorMessage [
string
]: The error message. Default isundefined
. * criterions [function
]: The criterion of required. for example: (value) => value !== '123'. Default is (value) => value !== undefined
- errorMessage [
- regex [
regex
]: regex string - options [
object
]:- errorMessage [
string
]: The error message. Default isundefined
.
- errorMessage [
- bound [
array
]: The boundary of string length. For example: [0, 10] where 0 is lower bound and 10 is upper bound. - options [
object
]:- errorMessage [
string
]: The error message. Default isundefined
. - mode [
string
]: The mode of bound. Same as StringLen.
- errorMessage [
- title [
string
]: The title name.
- value [
any
]: The default value
- check [
() => return bool
]: A method to define how to validate class member. Default isnull
. - enhancer[
(refObj, instanceObj) => ()
]: A method to enhance class member. You can add any method on to instanceObj. Default isnull
.- refObj [
object
]: An object saved in closure. Its' shape is { value, error } - instanceObj [
object
]: An object with method to operate refObj. The default operator is val and err.
- refObj [
- message [
string
]: Error message
- getValues [
() => return object
]: Get all values in class members. The return value would be an object with key pair format. - setValues [
props => {}
]: Set props into class. The property dismatch with class would be ignored. - clone [
() => return model
]: Clone an instanced model. - isEqual [
() => return bool
]: Compare with two models. It should be noticed that it's a shallow comparison. - checkErrors [
() => return array
]: Check all class member if there is an validation error. If true, the result would be presented as array of errors.