Validation Rule for an Array Key

Posted 3 months ago by xtremer360

I'm trying to figure out what I would do for a validation rule so that type2 cannot be in any of the groups of students. I know of the Rule::In but not sure how I can validate against a key.

'courses.*.students.*.*' => [Rule::in(['type2'])],

Can someone tell me what I'm doing wrong?

array:1 [
    "courses" => array:1 [
        1 => array:3 [
            "students" => array:2 [
                0 => array:2 [
                    "type1" => array:1 [
                       0 => 1
                    ]
                    "type2" => array:1 [
                        0 => 3
                    ]
                ]
                1 => array:1 [
                     "type1" => array:1 [
                          0 => 2
                     ]
                 ]
            ]
           "preview" => "This is an example couse preview."
        ]
    ]
]

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