Skip to content

$ANY$ expressions do not validate correctly #414

@bennmapes

Description

@bennmapes

Currently when using an $ANY$ expression in a visibleIf statement it does not validate correctly on number fields or anything without a length property such as numbers, booleans etc.

The way it's currently testing for validity of a value with $ANY$ is with this:

valid = value && value.length > 0;

I'm proposing we change that to something that can handle all possible values such as:

if(Array.isArray(value)) {
  valid = value.length > 0;
} else if(typeof value === "number") {
  valid = true;
} else if(typeof value === "boolean") {
  valid = true;
} else if(typeof value === "string") {
  valid = value !== '';
} else if(typeof value === "object") {
  valid = value !== null && value !== {};
}

Pull request with this change to follow. Feel free to share thoughts/improvements on this solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions