webmozarts/assert

Feature Request: Check that multiple specific keys exist in an array

Open

#258 opened on Oct 28, 2021

View on GitHub
 (1 comment) (1 reaction) (0 assignees)PHP (145 forks)batch import
help wanted

Repository metrics

Stars
 (7,454 stars)
PR merge metrics
 (Avg merge 5d 16h) (1 merged PR in 30d)

Description

Whats about adding assertions for multiple array key existence.

Assert::keysExists(array $value, array $keys) Check if all of provided key are presented in array May be useful for validation of POST/PUT request where requester must provide entire object.

Assert::oneOfKeysExists(array $value, array $keys) Check if at least one of provided key are presented in array May be useful for validation of PATCH request where all fields can be optional but at least one must be provided.

Contributor guide