Slim-Validation icon indicating copy to clipboard operation
Slim-Validation copied to clipboard

Use Key with Route Params

Open miquellaboria opened this issue 5 years ago • 6 comments

How can I use Key with Route Params:

$app->delete('/group/{groupId}/access/{userId}', '\App\Controller\Group:removeUser') ->add(new \App\Lib\Validation(array( v::oneOf( v::key('groupId',v::IsPublicationOwner($container)), v::key('userId', v::ItsMe($container)) ) )));

Returns:

At least one of these rules must pass for null Key groupId must be present Key userId must be present

miquellaboria avatar May 18 '19 11:05 miquellaboria

Hi @miquellaboria . What are you trying to do here? Do you want validation for both or only one of them?

DavidePastore avatar May 19 '19 14:05 DavidePastore

Hi @DavidePastore I want to validate at least one of them.

Thanks!

miquellaboria avatar May 19 '19 16:05 miquellaboria

@miquellaboria This is a nice use case. Can you please check if #40 fixes it and make it works as expected?

DavidePastore avatar May 26 '19 17:05 DavidePastore

@DavidePastore I have the same validation error: At least one of these rules must pass for null\nKey groupId must be present\nKey userId must be present

Key are not found :(

miquellaboria avatar May 26 '19 18:05 miquellaboria

Hi, this #40 worked here. Here's my code:

$app->get('/cliente', ClienteController::class . ':listarClientes')->add(new \DavidePastore\Slim\Validation\Validation( v::oneOf( v::key('test', v::notBlank()), v::key('test2', v::notBlank()) ) ));

alissonbezerra avatar Jun 07 '19 17:06 alissonbezerra

@miquellaboria I expected that it worked as @alissonbezerra said. Let's investigate it. What is the definition of \App\Lib\Validation?

DavidePastore avatar Jun 22 '19 17:06 DavidePastore