Created
March 24, 2023 13:37
-
-
Save wellserrano/0c5ddffc9c06f1ddf7e578500c38a1ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handlePassword() { | |
const passwordRegexRules = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z])(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ | |
const isPasswordValid = passwordRegexRules.test(password) | |
if (!isPasswordValid) Alert.alert('Invalid password. Password must contain at least one uppercase letter, one digit, one special character and be 8 charachters long') | |
} | |
<TextInput | |
textContentType="password" | |
secureTextEntry | |
value={ password } | |
onChangeText={ setPassword } | |
onBlur={ handlePassword } | |
> | |
Senha | |
</TextInput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regex Rules
Length: 8
Special characters: @$!%*?&
At least: 1 digit, 1 uppercase character