如何在循环中验证所有 reduxForm 字段?

问题描述

我有一个授权表,其中存在 2 个 <Col></Col>,而且很容易验证。这是我的做法:

Field
const reducers = {
    // ... your other reducers here ...
    form: formReducer
}
const reducer = combineReducers(reducers)
const store = createStore(reducer)





class Authorization extends Component {
    constructor() {
        super();
    }

    render() {
        return (
        <Provider store={store}>
              <AuthForm/>
         </Provider>
        )
    }
}



AuthForm extends Component {
    validate_login = values => {
        console.log("Validating login... Login is",values)
    }
    validate_pwd = values => {
        console.log("Validating password... Passwd is",values)
    }
    render() {
        const { handleSubmit } = this.props
        return (
            <form onSubmit={handleSubmit} className="authorization-center-wrapper">
                <div className="authorization-column-wrapper">
                    <label className="authorization-RTA-text" onClick={this.home_page}>RTA</label>
                    <label className="authorization-auto-text">AUTH</label>
                    <div className="authorization-center-content">
                        <Field validate={[this.validate_login]} name={"login"} component={'input'} type="text" placeholder="Email" className="authorization-login-input"/>

                        <Field validate={[this.validate_pwd]} name={"password"} component={'input'} type="password" placeholder="Password" className="authorization-password-input"/>

                        <button className="authorization-come-in-btn" type={"submit"}>Log in</button>
                        <p className="authorization-forgot-password" onClick={this.forgot_pass}>Forgot password?</p>
                        <Link to={"/reg"} className="authorization-reg-btn" onClick={this.reg_page}>Sign up</Link>
                    </div>
                </div>
            </form>
        )
    }


}


AuthForm = reduxForm({
    // a unique name for the form
    form: 'authorization'
})(AuthForm)



ReactDOM.render(<Authorization/>,document.getElementById("root"));

现在工作正常,但我有注册表,其中有 10 个字段。是否存在任何循环或用于检查值是否为空的循环? (最好没有验证属性),我在互联网上找不到任何解决方案。

无法制作可重现的代码,因为不知道如何在 stackoverflow 中使用 react

提前致谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)