Comments (12)
I’ve actually thought about this one before, it’s not quite that easy because if you pass all the rules and values, they will have error messages before you even type in a field possibly, which would be a problem. May need a slightly bigger change. Do you see what I’m saying? Thanks for bringing this up
from validify.
I agree is a mayor change. But to rules with multiple value validation works, the values are needed. Pass all rules is not needed, just the rule of the field, as your code shows.
This little change allow use other fields in a custom rule too. For example, if I have a field with a rule using the second password field value ( named 2ndPass) in it, I can use this code to get the value:
Validator.register('myRule', function(value, requirement, attribute) {
// Here we get the value of another field
const secondPasswordValue = this.validator._flattenObject(this.validator.input)['2ndPass'];
// Rule evaluation here
return true of false; // It depends of evaluation
} , 'My Rule fail on field :attribute');
from validify.
I am having serious troubles because of this rule not working :( I really need it for password confirmation.
from validify.
I tried with the confirmed rule but it does not work.
from validify.
@diegoper94 add "required|" to your password fields then you will not have an issue
from validify.
Yes but i need the password and confirm password fields to match, for that i need same: rule or confirmed but both of then dont work.
from validify.
@diegoper94 show your rules. If you simply put required in addition to those rules, it will work.
from validify.
import { Form } from 'react-validify';
import Input from '../CreateRecipe/Input';
class SignUp extends Component {
render() {
return (
<div className="container">
<div className="row">
<div className="offset-md-3 col-md-6">
<h2 className="create-recipe__header">Sign Up</h2>
<Form
rules={{
userName:'required|min:3',
password:'required|between:6,10',
password_confirmation:'required|same:password',
email:'required|email'
}}
errorMessages={{
'required.userName': 'Please provide a user name',
'min.userName': 'The user name must contain at least 3 characters',
'required.password': 'Please set a password',
'between.password': 'The password must contain from 6 to 10 characters',
'required.email': 'Please provide a email',
'email.email': 'Please provide a valid email'
}}>
<div className="form-group">
<label htmlFor="userName">User Name</label>
<Input className="form-control" name="userName" id="userName" placeholder="example123" />
<label htmlFor="password">Password</label>
<Input className="form-control" name="password" id="password" type="password" />
<label htmlFor="password_confirmation">Confirm Password</label>
<Input className="form-control" name="password_confirmation" id="password_confirmation" type="password" />
<label htmlFor="email">Email Address</label>
<Input className="form-control" name="email" id="email" placeholder="[email protected]" />
</div>
<div>
<button submit className="btn btn-success">Submit <i className="fas fa-arrow-circle-right"></i></button>
</div>
</Form>
</div>
</div>
</div>
)
}
}
export default SignUp;
from validify.
does this work? https://github.com/skaterdav85/validatorjs#confirmed
from validify.
It does not work also :( I really enjoy this library because it is easy and simple to use please could you fix that?
from validify.
I would fix it by myself and share the fix but i am a begginer just playing around with react.
from validify.
@diegoper94 if you would like me to debug it, please make a single file that I can paste into create-react-app that has your issue. So make a new CRA, and make it not work inside the index.js and i will copy and try to see whats wrong :)
from validify.
Related Issues (13)
- Validated Form loses submit Event Listener HOT 11
- Can't clear value of inputs after form submit HOT 7
- Validation outside Form component HOT 2
- Checkbox and radio validation HOT 11
- Values are not updated when typing HOT 2
- validate dates HOT 6
- Async Validation HOT 1
- Implement onValue as an alternative to onValues HOT 2
- default value for input is not working HOT 3
- required_if:anotherfield,value rule not working HOT 12
- Recursive cloning of elements is missing top level element HOT 1
- onBlur validation produces undesired ui effect HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validify.