{
const reg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (reg.test(String(email).toLowerCase())) {
return true;
} else {
return 'is not a valid email address';
}
}
}}
/>
```
### Q: What if my variables got cached due to the react memoization?
**A**: You can always pass the value you wish to update into ```validationOption```.
for the below example, just put ```balance``` inside ```validationOption``` and it will not be cached.
```js
...
const AmountInputComponent = memo(({balance, locale}) => {
const [amount, setAmount] = useState('')
const handleAmountValidate = useCallback(
res => {
if (Number(res) > Number(Balance)) {
return `Amount should not be great than ${balance} USD`;
}
return true
},
[balance],
);
return (
{}}
onChange={res => setAmount(res)}
validationOption={{
type: 'number',
numberType: 'decimal',
required: false,
customFunc: async v => {
return handleTestValidate(v);
},
locale: locale,
balance: balance, // put the balance inside validationOption and it will not be cached.
}}
/>
);
});
```
### Q: Do you support custom locales?
**A**: Yes, and it could be multiple locales. By providing ```window.REACT_INPUTS_VALIDATION['customErrorMessage']```, you can overwrite the error message.
codesandbox example(located in index.html)
example(fully customized):
**es6** ([full es5 example](/docs/locales-example-es5.md), [full es6 example](/docs/locales-example-es6.md))
```html