Validation issue with Select component
rampanwar opened this issue · 3 comments
rampanwar commented
I have a payment form. I've created Year and Month input using the Select component. It sets the state correctly, But validationCallback always returns hasErr=true. Both the id, name params in each option are string, and I've set it to check just for required: true.
const years = [
{id: "2020", name: "2020"}
{id: "2021", name: "2021"}
{id: "2022", name: "2022"}
{id: "2023", name: "2023"}
{id: "2024", name: "2024"}
]
<Select
attributesInput={{ name: "card_exp_year" }}
value={card_exp_year}
validate={validating}
optionList={[
{ id: "", name: "Select Year" },
...years
]}
onChange={(val, e) =>
this.handleChange({ target: { name: 'card_exp_year', value: val.id } })
}
validationOption={{ name: 'Year', required: true }}
validationCallback={hasErr =>
this.handleValidation("card_exp_year", hasErr)
}
/>
Besides, the same issue is there in your demo https://edwardfhsiao.github.io/react-inputs-validation/.
edwardfxiao commented
I will take a look
edwardfxiao commented
Hi @rampanwar ,
Thank you for your feedback, now try version 4.3.4, should be working now.
rampanwar commented
Awesome! that works now ..
I was avoiding the Select component just because of this issue, now it's perfect.
Thanks a lot for helping out so quickly