samedi 15 juillet 2023

Validation - Laravel [closed]

{
    "status": true,
    "message": {
        "main_1": {
            "chalet_main_facility_sub_facilities": [
                "sub_1",
                "sub_2",
                "sub_3"
            ]
        },
        "main_2": {
            "chalet_main_facility_sub_facilities": [
                "sub_1",
                "sub_2",
                "sub_3"
            ]
        },
        "ma": {
            "chalet_main_facility_sub_facilities": [
                "sub_1"
            ]
        }
    }
}

the array key "main_1", "main_2" and "ma" must be required|string|max:45 ??

I have a database like this chalet_main_facilities contains a title this title is 45 max length and each chalet_main_facilities contains chalet_main_facility_sub_facilities contains a title this title is 75 max length

chalet_main_facilities Table

chalet_main_facility_sub_facilities Table

laravel validator ↴

$validator = Validator($request->all(), [
    'chalet_main_facilities' => 'required|array|min:1',
    'chalet_main_facilities.*' => 'required|array|distinct|size:1',
    'chalet_main_facilities.*.chalet_main_facility_sub_facilities' => 'required|array|min:1',
    'chalet_main_facilities.*.chalet_main_facility_sub_facilities.*' => 'required|string|min:3|max:255',

]);


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire