GithubHelp home page GithubHelp logo

Comments (12)

zackify avatar zackify commented on August 22, 2024

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.

CharlieMarket avatar CharlieMarket commented on August 22, 2024

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.

dper94 avatar dper94 commented on August 22, 2024

I am having serious troubles because of this rule not working :( I really need it for password confirmation.

from validify.

dper94 avatar dper94 commented on August 22, 2024

I tried with the confirmed rule but it does not work.

from validify.

zackify avatar zackify commented on August 22, 2024

@diegoper94 add "required|" to your password fields then you will not have an issue

from validify.

dper94 avatar dper94 commented on August 22, 2024

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.

zackify avatar zackify commented on August 22, 2024

@diegoper94 show your rules. If you simply put required in addition to those rules, it will work.

from validify.

dper94 avatar dper94 commented on August 22, 2024
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.

zackify avatar zackify commented on August 22, 2024

does this work? https://github.com/skaterdav85/validatorjs#confirmed

from validify.

dper94 avatar dper94 commented on August 22, 2024

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.

dper94 avatar dper94 commented on August 22, 2024

I would fix it by myself and share the fix but i am a begginer just playing around with react.

from validify.

zackify avatar zackify commented on August 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.