cleanup validators and allow string return as error message

This commit is contained in:
cupcakearmy
2019-10-19 20:15:54 +02:00
parent 43db9630a4
commit 6070ee2227
3 changed files with 16 additions and 16 deletions

View File

@@ -15,13 +15,14 @@ const initial = {
const Index: React.FC = () => {
const { field, form, errors, isValid, setForm, setErrors, setField } = useForm(initial, {
username: [
/^test/,
/^abc/,
{
validator: async () => {
validator: async (s: string) => {
return true
},
message: 'Digits please',
message: 'Async shit not working',
},
(s: string) => (s.includes('d') ? true : 'Needs the D'),
],
password: {
validator: /^.{3,}$/,