mardi 9 juin 2020

laravel custom validation inside in array

    array:3 [
0 => array:5 [
    "question_text" => "1. What is the first question?"
    "options" => array:4 [
      0 => "A. First answer"
      1 => "B. Second answer"
      2 => "C. Third answer"
      3 => "D. Forth answer"
    ]
    "answer" => "A"
    "points" => "10 "
    "type" => "MC"
  ]
1 => array:5 [
    "question_text" => "2. What is the second question? This question is of multiple lines and it can go into 2 or 3 or 4 lines, but                    make sure you import it correctly."
    "options" => array:2 [
      0 => "A. Yes, I got it"
      1 => "B. No, I can’t"
    ]
    "answer" => "A"
    "points" => "10"
    "type" => "MC"
  ]
 2 => array:5 [
    "question_text" => "3. This is an open ended question."
    "options" => []
    "answer" => " "
    "points" => "10"
    "type" => " O"
  ]
]

I have this type array in laravel (not request array,that is data come from docx file),I want to validate all data in this format.

validation like if type is M at time options and anwer field is required. and question_text and points all tym required.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire