common-validator
validator, for everywhere
usage looks like below:
thisvalidator = phone: message: "请填写电话号码" thisstatephone patterns: reg: /^\d{11}$/ message: "电话号码应为11位数字" captcha: message: "请填写验证码" thisstatecaptcha patterns: reg: /^\d{4}$/ { //todo... } { /* do your own logic. like: this.setState({ [key+"Msg"]: message }) */}; let result = thisvalidator;ifresult //check passed. this{ let validator = this; return <View> <input onBlur=validator || validatorgetPhone/> <InputComponent validator=validator || validatorgetXxx/> </View> ;} InputComponent extends React