4 months ago

How to validate both the key and value of a request array

Posted 4 months ago by makapaka

Can anyone suggest how to do the following.

I have a request body

    "sell": {
         "111": [1 , 2 , 3]

I need to validate 111 as an id on one table, and 1, 2, 3 as ids that exist on a different table.

What is the format for this ?

'sell' => 'required|sell|exists:stock,id',
'sell' => 'required|sell|exists:exchange,id'

Ie, table stock should contain ids of 1, 2, 3; table exchange should contain id 111 - which is also FK exchange_id in stock table.

That's not right is it, how do I indicate validation for both the key and values of the sell element ? Hope this makes sense


Please sign in or create an account to participate in this conversation.