Horalo
Horalo

Reputation: 11

Kotlin Code to Validate a Confirmation of Password

Need code to validate the confirmation of password, included is the validation of password field:

    private fun passwordValidate(text: String?): Boolean {
        var p = Pattern.compile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@\$!%*?&])[A-Za-z\\d@\$!%*?&]{5,20}\$")
        var m = p.matcher(text)
        return m.matches()
    }

The confirm password I would guess would start of similar as follows:

    private fun confirmpasswordValidate(text: String?): Boolean {
        var p = Pattern.compile

Upvotes: 1

Views: 193

Answers (1)

Gebes
Gebes

Reputation: 347

I assume that you do not need any extra method to validate the confirmpassword. You should first check if the passwords are the same and if they are, then simply check the first password with your passwordValidate method.

Upvotes: 2

Related Questions