You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
Thank you for such a awesome project! It's very elegant!
Package version
"indicative": "^7.4.4",
Node.js and npm version
v13.12.0
At first I used the email rule but noticed a bug where the validation would stop (causing my message to disappear) when reaching the @ symbol, So the user could conceivably enter something like foo@gmail, so I figured why not use a regex; With the Regex the message persists despite entering a valid email...
See below.
Sample Code (to reproduce the issue)
var data = {
username: username,
password: password
};
var schema = {
username: [
validations.regex([
new RegExp(
'/^(([^<>()[]\\.,;:s@"]+(.[^<>()[]\\.,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/'
)
])
],
password: 'min:7|max:11'
};
var messages = {
regex: 'Make sure this is a valid email!!',
min: 'The value is too short',
max: 'The value is too long'
};
validateAll(data, schema, messages)
.then(success => {
if (success.username) {
console.log('success.username ', success.username);
setUsernameError(false);
}
if (success.password) {
console.log('success.password ', success.password);
setPasswordError(false);
}
if (success.username && success.password) {
console.log('success.username ', success.username);
setDisableButton(false);
}
})
.catch(errors => {
console.log('errors ', errors);
if (errors[0].field === 'username') {
setUsernameError(true);
setDisableButton(true);
setUsernameFeedback(errors[0].message);
}
if (errors[0].field === 'password') {
setPasswordError(true);
setDisableButton(true);
setPasswordFeedback(errors[0].message);
}
});
It is tough to validate an email, you may not know it, but test@ch is a valid email address.
The only rule to have a valid address is to have @ inside it.
Thank you for such a awesome project! It's very elegant!
Package version
"indicative": "^7.4.4",
Node.js and npm version
v13.12.0
At first I used the
email
rule but noticed a bug where the validation would stop (causing my message to disappear) when reaching the@
symbol, So the user could conceivably enter something likefoo@gmail
, so I figured why not use a regex; With the Regex the message persists despite entering a valid email...See below.
Sample Code (to reproduce the issue)
BONUS (a sample repo to reproduce the issue)
FormComponent
validate
The text was updated successfully, but these errors were encountered: