webmozarts/assert

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

Open

#258 ouverte le 28 oct. 2021

Voir sur GitHub
 (1 commentaire) (1 réaction) (0 assignés)PHP (145 forks)batch import
help wanted

Métriques du dépôt

Stars
 (7 454 stars)
Métriques de merge PR
 (Merge moyen 5j 16h) (1 PR mergée en 30 j)

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.

Guide contributeur