如何在redux形式的validate函数中不返回字符串

如何在redux形式的validate函数中不返回字符串,redux,react-redux,redux-form,Redux,React Redux,Redux Form,我有一个带有输入字段和同步验证的表单。同步验证将生成一条错误消息,错误消息将显示在输入字段下方 但是,在某些情况下,我只希望输入字段有一个红色边框,没有错误消息。我尝试使用字段级验证 import {validateDateString} from "some/path"; const renderField = ({input, value, meta: {touched, asyncValidating, error, valid}}) => {

我有一个带有输入字段和同步验证的表单。同步验证将生成一条错误消息,错误消息将显示在输入字段下方

但是,在某些情况下,我只希望输入字段有一个红色边框,没有错误消息。我尝试使用字段级验证

import {validateDateString} from "some/path";

const renderField = ({input, value, meta: {touched, asyncValidating, error, valid}}) => {
        return (
            <div className=`${validateDateString(input.value) ? '': 'border-error'}`>
                <input type="text" {...input}/>
                {touched && error && <div className="form-group__error">{error}</div>}
            </div>
        );
};

const validate = (dateString) => {
   if(validateDateString(dateString)) return undefined;
   return false; 
}
从“some/path”导入{validateDateString};
const renderField=({input,value,meta:{toucted,asyncValidating,error,valid}})=>{
返回(
{触摸&&error&&{error}
);
};
常量验证=(日期字符串)=>{
if(validatedtestring(dateString))返回undefined;
返回false;
}
后来我的领域看起来像这样:

  <Field
        name={"myName"}
        component={renderField}
        validate={validate}
    />

在字段级验证中,我不希望显示错误消息,只希望在同步验证中显示。因此,我不想在我的
validate
函数中返回字符串,因为该字符串将显示在输入字段下方。假设它不必是字符串,所以我返回
false

如果该值无效,则验证函数应返回 错误。这通常是一个字符串,但不一定是

但似乎不起作用:表单仍在提交中。我是否在验证函数中出错,或者是否有其他方法阻止表单手动提交