asigloo / vue-dynamic-forms

Easy way to dynamically create reactive forms in Vue based on a varying business object model
https://vue-dynamic-forms.netlify.app/
MIT License
395 stars 45 forks source link

field matching? #305

Open Fanna1119 opened 2 years ago

Fanna1119 commented 2 years ago

Is your feature request related to a problem? Please describe.

when it comes to validation, sometimes you really need to match 2 fields. consider the following for example.


const form = computed(() => ({
  id: "my-awesome-form",
  fields: {
    name: EmailField({
      label: "Email",
      validations: [
        Validator({ validator: required, text: "This field is required" }),
        Validator({
          validator: validateEmail,
          text: "Format of email is incorrect",
        }),
      ],
    }),
    password: PasswordField({
      label: "Password",
      validations: [
        Validator({ validator: required, text: "This field is required" }),
      ],
    }),
    confirmpassword: PasswordField({
      label: "Confirm Password",
      validations: [
        Validator({ validator: required, text: "This field is required" }),
        Validator({validator: (value: String) => value === form.password, text: "Passwords do not match"}),
      ],
    }),
  },
}));

const formSubmitted = (e: any) => {
  console.log(e);
};

confirmpassword needs to match password

Describe the solution you'd like

Ability to match 2 fields

Describe alternatives you've considered

No response

Additional context

No response

Validations