react-native-form-validator icon indicating copy to clipboard operation
react-native-form-validator copied to clipboard

this.isFormValid is always true.

Open tejparekh opened this issue 7 years ago • 1 comments

When i console.log(this.isFormValid); Result : ƒ isFormValid() { return this.errors.length == 0; }

`import ValidationComponent from 'react-native-form-validator';

export default class extends ValidationComponent { constructor(props) { }

// onPress of the Submit button I am invoking this function to validate all my fields. submitCredentials = () => {

    // TODO : Get the Location details 
    // TODO : Validate the type of data in the Regsiter Form 
    // TODO : 
    console.log("Validating the Form"); 
    this.validate({
        _password   : {required: true},
        _email      : {email: true},   // Sample: I am entering the "sdfjhsbdjfh" in the email field
        _name       : {required: true},
        _lastname   : {required: true},
        _phone      : {numbers: true}, 
        _alias_name : {required: true},
        _isd        : {required: true},
    })
    console.log(this.isFormValid); // returns the function on console
    if(this.isFormValid){   // Always true even if incorrect data is entered in form. 
        this.fireRegisterAPI();
    }

}`

Please help with the solution. What am I missing here? Any setup issue? TIA

tejparekh avatar Nov 16 '18 00:11 tejparekh

You are logging the function not calling the function console.log(this.isFormValid()) not console.log(this.isFormValid)

asdf23 avatar Nov 13 '20 00:11 asdf23