Skip to content

Instantly share code, notes, and snippets.

@wellserrano
Created March 24, 2023 13:37
Show Gist options
  • Save wellserrano/0c5ddffc9c06f1ddf7e578500c38a1ac to your computer and use it in GitHub Desktop.
Save wellserrano/0c5ddffc9c06f1ddf7e578500c38a1ac to your computer and use it in GitHub Desktop.
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>
@wellserrano
Copy link
Author

Regex Rules

Length: 8
Special characters: @$!%*?&
At least: 1 digit, 1 uppercase character

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment