added arrays of validators

This commit is contained in:
cupcakearmy
2019-09-28 19:00:49 +02:00
parent f402146f87
commit 47748b568e
3 changed files with 76 additions and 26 deletions

View File

@@ -10,13 +10,19 @@ const TextError: React.FC<{ error?: string }> = ({ error }) => !error
const Index: React.FC = () => {
const { auto, form, errors } = useForm({
const { auto, form, errors, isValid } = useForm({
username: '',
password: '',
type: 'formhero',
awesome: true,
}, {
username: /^test/,
username: [
/^test/,
{
validator: async () => { return true },
message: 'Digits please',
}
],
password: {
validator: /^.{3,}$/,
message: 'To short',
@@ -26,7 +32,7 @@ const Index: React.FC = () => {
const _submit = (e: React.FormEvent) => {
e.preventDefault()
console.log(form, errors)
console.log(form, errors, isValid)
}
return (