NewOldMax / react-form-validator-core

Core validator component for react forms
MIT License
94 stars 44 forks source link

Async Validator Rule #17

Closed Donskelle closed 6 years ago

Donskelle commented 6 years ago

Hey Guys, i want to add a new validation rule to check if mail is available. Somethink like

ValidatorForm.addValidationRule('isEmailAvailable', (value) => {
        axios.post('/api/users/emailavailable', formDataClear)
            .then((response) => {
                if (response.data == "ok") {
                    return true
                } 
                return false
        })
    });

Is there a way to set async validators?

NewOldMax commented 6 years ago

Hi, currently you can't achieve it in some clear and reusable way but you can try to do something like this

Donskelle commented 6 years ago

Nice i can use that. Thanks for quick response.