나는 두 시간 동안 작업에 어려움을 겪고 있습니다. 나는 재료 UI에서 REDUX 양식 텍스트 필드가 있고 난이처럼 사용redux -form 형식의 텍스트 필드 내부에서 유효성 확인
<Field
id="searchCif"
name="searchCif"
component={TextField}
floatingLabelText={SEARCHVIEW_HINT_CIF}
disabled={(afm !== undefined)}
validate={[requireValidator, onlyNumeric]}
/>
유효성 검증은 인수 두 가지 기능으로 걸릴 소품
:
const requireValidator = (value, intl) => (
value === undefined ? intl.formatMessage({ id: 'error.search.cif.afm' }) :
undefined
);
const onlyNumeric = (value, intl) => (
(value !== undefined && !(/^([0-9])+$/g).test(value)) ?
intl.formatMessage({ id: 'error.search.cif.afm.only.number' }) :
undefined
);
나는 국제을 사용하여 내 메시지를 번역해야하기 때문에 . 그러나 intl.formatted message is not a function
오류가 표시됩니다. 그러므로 나는 다음과 같이 썼다 : validate={() => [requireValidator(value, intl), onlyNumeric(value, int)]}
. 오류가 표시되지 않지만 유효성 검사가 제대로 작동하지 않습니다. 어떤 아이디어?
int로 무엇을 전달합니까? 당신의 코드에서, console.log (typeof'당신이 intl로 전달하는 것) 무엇이 출력됩니까? –
Intl은 로캘이며 문자열 형식 인 – user7334203
은 int를 가져 오므로 formatMessage 메서드를 사용할 수 있습니까? 당신의 import/require 문을 볼 수 있습니까? –