## Classes
FieldCheck
FormVerify

FormItem 表单验证类

## FieldCheck **Kind**: global class **Properties** | Name | Type | Description | | --- | --- | --- | | ruleItems | Array.<ruleItem> |

验证规则

| | addRuleItem | function |

添加一条验证规则

| | verify | function |

检查表单是否符合规则

| * [FieldCheck](#FieldCheck) * [new FieldCheck()](#new_FieldCheck_new) * [._isEmpty(v)](#FieldCheck+_isEmpty) * [._isRegExp(v)](#FieldCheck+_isRegExp) * [.buildRuleItem(checkFields, ruleArr)](#FieldCheck+buildRuleItem) ⇒ ruleItem * [.addRuleItem(ruleName, checkFields, ruleArr)](#FieldCheck+addRuleItem) ⇒ * [.getRuleItem(field)](#FieldCheck+getRuleItem) ⇒ * [.checkField(field, value)](#FieldCheck+checkField) ⇒ Array.<(checkCode\|?errMessage)> * [.verify(formObject, [isMustMatch])](#FieldCheck+verify) ⇒ ### new FieldCheck()

表单字段验证类

**Example** ```js let fieldCheck = new FieldCheck(); fieldCheck.addRuleItem('rule1',['name'],[ { type: 'string', minLength: 2, maxLength: 10, message: '姓名必须为2-10个字符' } ]); fieldCheck.addRuleItem('rule2',['age'],[ { type: 'number', min: 18, max: 100, message: '年龄必须为18-100岁' }]); let errMsg = fieldCheck.verify({ name: 'kindring', age: 18}); console.log(errMsg); // null let errMsg = fieldCheck.verify({ name: 'kindring', age: 17}); console.log(errMsg); // 年龄必须为18-100岁 ``` ### fieldCheck.\_isEmpty(v)

判断是否为空

**Kind**: instance method of [FieldCheck](#FieldCheck) | Param | Description | | --- | --- | | v |

要检验的值

| ### fieldCheck.\_isRegExp(v)

判断是否为正则

**Kind**: instance method of [FieldCheck](#FieldCheck) | Param | Description | | --- | --- | | v |

要检验的值

| ### fieldCheck.buildRuleItem(checkFields, ruleArr) ⇒ ruleItem

构建验证规则

**Kind**: instance method of [FieldCheck](#FieldCheck) **Returns**: ruleItem -

验证规则对象

| Param | Type | Description | | --- | --- | --- | | checkFields | Array.<(string\|RegExp)> |

需要验证的字段

| | ruleArr | Array.<(validatorFunction\|checkRule)> |

验证规则

| ### fieldCheck.addRuleItem(ruleName, checkFields, ruleArr) ⇒

添加一条验证规则

**Kind**: instance method of [FieldCheck](#FieldCheck) **Returns**:

返回当前对象

| Param | Description | | --- | --- | | ruleName |

验证规则名,用于区分

| | checkFields |

用于匹配字段的字符或者正则数组

| | ruleArr |

验证规则

| ### fieldCheck.getRuleItem(field) ⇒

获取验证规则

**Kind**: instance method of [FieldCheck](#FieldCheck) **Returns**:

验证规则

| Param | Description | | --- | --- | | field |

字段名

| ### fieldCheck.checkField(field, value) ⇒ Array.<(checkCode\|?errMessage)>

检查字段是否符合规则

**Kind**: instance method of [FieldCheck](#FieldCheck) **Returns**: Array.<(checkCode\|?errMessage)> -

错误码或错误信息

| Param | Description | | --- | --- | | field |

字段名

| | value |

字段值

| ### fieldCheck.verify(formObject, [isMustMatch]) ⇒

检查表单是否符合规则

**Kind**: instance method of [FieldCheck](#FieldCheck) **Returns**:

errMessage 错误码或错误信息

| Param | Type | Default | Description | | --- | --- | --- | --- | | formObject | verifyForm | |

需要检验的表单项 字段:值

| | [isMustMatch] | | false |

是否强制要求匹配规则

| ## FormVerify

FormItem 表单验证类

**Kind**: global class * [FormVerify](#FormVerify) * [new FormVerify(formObject, [fieldCheck], [option])](#new_FormVerify_new) * _instance_ * [.checkForm(form, isMustMatch)](#FormVerify+checkForm) ⇒ boolean * [.check([isMustMatch])](#FormVerify+check) * _static_ * [.buildFormItem(object, field, formItemData, fieldCheck, isMustMatchRule)](#FormVerify.buildFormItem) ⇒ * [.initFormItemData(formObject)](#FormVerify.initFormItemData) ### new FormVerify(formObject, [fieldCheck], [option])

表单项

| Param | Type | Description | | --- | --- | --- | | formObject | formObject |

表单项数据

| | [fieldCheck] | [FieldCheck](#FieldCheck) |

字段验证对象

| | [option] | object |

配置项

| ### formVerify.checkForm(form, isMustMatch) ⇒ boolean

检查表单项是否符合要求

**Kind**: instance method of [FormVerify](#FormVerify) | Param | Type | Description | | --- | --- | --- | | form | formObject |

表单对象

| | isMustMatch | |

是否必须全部匹配到验证规则

| ### formVerify.check([isMustMatch])

验证当前的表单是否符合要求

**Kind**: instance method of [FormVerify](#FormVerify) | Param | Default | Description | | --- | --- | --- | | [isMustMatch] | false |

是否必须全部匹配到验证规则

| ### FormVerify.buildFormItem(object, field, formItemData, fieldCheck, isMustMatchRule) ⇒

检查表单项是否符合要求

**Kind**: static method of [FormVerify](#FormVerify) **Returns**:

errMsg 错误信息

| Param | Description | | --- | --- | | object |

表单项数据

| | field |

字段名

| | formItemData |

表单项数据

| | fieldCheck |

字段验证对象

| | isMustMatchRule |

表单字段是否必须匹配到验证规则

| ### FormVerify.initFormItemData(formObject)

初始化表单项数据

**Kind**: static method of [FormVerify](#FormVerify) | Param | Type | Description | | --- | --- | --- | | formObject | formObject |

表单对象

|