Skip to content

Add ability to require at least one of multiple validation methods #2457

Closed
@rodrigoaguilera

Description

@rodrigoaguilera

New feature motivation

I have an input that accepts Spanish nie and Spanish nif. Specifiying one of the formats is enough to pass validation.

New feature description

Have a new "metamethod" that allows for defining this kind of behavior

New feature implementation

Right now the format for rules "ands" all the rules as far as I know like

  rules: {
    // simple rule, converted to {required:true}
    name: "required",
    // compound rule
    email: {
      required: true,
      email: true
    }
  }

The email needs to pass required AND email methods.

A suggestion on how it could look like in the configuration:

  rules: {
    nifcif: {
      oneof: {
        nifES: true,
        nieES: true
      }
    }
  }

Maybe there is already a way to define this but I'm not aware of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions