Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Nested Object Validation #32

Closed
kdaker opened this issue Aug 9, 2018 · 2 comments
Closed

Support Nested Object Validation #32

kdaker opened this issue Aug 9, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@kdaker
Copy link

kdaker commented Aug 9, 2018

Assume we have the following list of rules to be validated as a application/json post:

 $rules = [
    'message' => [
        'notification' => [
            'title' => v::stringType()->length(1, null)->setName("notificationTitle"),
            'body' => v::stringType()->length(1, null)->setName("notificationBody"),
            'actionName' => v::optional(v::stringType()->length(1, null))->setName("notificationAction")
        ]
    ]
];

If I were to post something like this:

{ 
    'message' :   {
        'notification' : 1
     }
}

an error exception is thrown instead of validating that notification should be an object.

Respect seems to have a way to solve with using the key method but we don't have access to that using the middleware.
Respect/Validation#317

exception:

Type: ErrorException
Message: array_key_exists() expects parameter 2 to be array, integer given
File: /path/vendor/davidepastore/slim-validation/src/Validation.php
Line: 163
@DavidePastore
Copy link
Owner

Hi @kdaker, thanks for opening this issue. You can try and use the 0.5.1 release that includes this bug fix.

@kdaker
Copy link
Author

kdaker commented Aug 15, 2018

will do @DavidePastore , thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants