Skip to content

Add enforce.arrayOf() rule #488

@ealush

Description

@ealush

This rule can be quite useful when a future schema validation rule will be added to enforce.

The general idea is quite similar to the enforce.any rule:

enforce(value).isArrayOf(
  enforce.isString(),
  enforce.isNumber(),
 enforce.isArrayOf(...) // Yeah, why not? A recursive call should be pretty simple here
)

The idea is that at least one needs to be truthy in order for the condition to be met - alternatively, an empty array should probably be valid as well unless explicitly mentioned:

enforce(value).isArrayOf(
  enforce.isString()
).isNotEmpty()

See Shape for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions