Skip to content

Validating array keys #143

Description

@rick-nu

What

In #116 @camcima presented a way to make array keys testable. With the given PR, array keys are converted into a value in the array, which then becomes testable the regular way. Thus, a key value "magically" appears in your data array.

We need to think if there is a better solution for this. For example if it would be possible to:

$v->required('products')->each(function (Validator $validator) {
    $validator->key()->regex('/^SKU\d{4}\-\d{3}/');
    $validator->required('price')->integer();
    $validator->required('quantity')->integer;
});

This issue is open to suggestions and pull requests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions