Exemple #1
0
    //checks if input fields is valid
    bool CheckDataValid()
    {
        UsernameError.text = "";
        PasswordError.text = "";

        IValidate UsernameValidator = new UsernameValidator(UsernameInput.text, usernameValidationData, UsernameError);
        IValidate PasswordValidator = new PasswordValidator(PasswordInput.text, passwordValidationData, PasswordError);

        bool isUsernameValid = UsernameValidator.isValid();
        bool isPasswordValid = PasswordValidator.isValid();

        ColorField(UsernameInput, isUsernameValid);
        ColorField(PasswordInput, isPasswordValid);

        return(isUsernameValid && isPasswordValid);
    }
    bool CheckRegistrationDataValid()
    {
        UsernameError.text        = "";
        EmailError.text           = "";
        PasswordError.text        = "";
        PasswordConfirmError.text = "";

        IValidate UsernameValidator = new UsernameValidator(UsernameInput.text, usernameValidationData, UsernameError);
        IValidate EmailValidator    = new EmailValidator(EmailInput.text, emailValidationData, EmailError);
        IValidate PasswordValidator = new PasswordValidator(PasswordInput.text, passwordValidationData, PasswordError);

        bool isUsernameValid = UsernameValidator.isValid();
        bool isEmailValid    = EmailValidator.isValid();
        bool isPasswordValid = PasswordValidator.isValid();

        ColorField(UsernameInput, isUsernameValid);
        ColorField(EmailInput, isEmailValid);

        isPasswordValid = CheckPassword(isPasswordValid);



        return(isUsernameValid && isEmailValid && isPasswordValid);
    }