Skip to content

Inconsistency between required and one_of #54

Description

@tpow

In #45 there was discussion about the difference between required and exists. Required means that the field exists and isn't empty.

In the documentation for validation, one_of is described as "Sometimes you will want only one of several fields to be required. At least one of them need to be required." This sounds like what I want -- I have a couple fields and I want the user to populate one of them and leave the other one blank (or optionally populate both).

However, in my testing with form input, one_of seems to be acting like it is testing that the fields exist but isn't testing that one of them is required. If I validate.required(["field1", "field2"]) it throws an error for both fields. However, validate.one_of(["field1", "field2"]) throws no errors.

If one_of is intentionally for exists_one_of, it would be helpful to have a required_one_of (or some other name). The documentation also needs to be clarified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions