-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Hello, I'm trying to make conditionals with isFieldInError and getErrorsInField, but it returned me false and an empty array respectively even having errors, this is my code, I'm doing like a reusable component.
function RegisterForm({data}) {
const [field, setField] = useState('');
const [value] = useDebounce(field, 1000);
const {validate, isFieldInError, getErrorsInField, getErrorMessages} =
useValidation({
state: {field},
});
const _validateForm = () => {
validate({
field: data.rules,
});
};
React.useEffect(() => {
if (value.length !== 0) {
_validateForm();
}
}, [value]);
return (
<View style={tailwind('px-8')}>
<TextInput
placeholder={data.placeholder}
style={[
tailwind('text-black p-0 text-xl pb-1 flex-row'),
{
borderBottomWidth: 1,
borderBottomColor: '#808080',
},
]}
onChangeText={text => setField(text)}
value={field}
/>
<Text>{getErrorMessages()}</Text>
<TouchableOpacity onPress={() => _validateForm()}>
<Text>auwhdauywd</Text>
</TouchableOpacity>
</View>
);
}
And I want to use custom messages but I don't know how, please help me, thank you
Metadata
Metadata
Assignees
Labels
No labels