I have a column in my database which it's json type: values
.
But I need to enforce a schema.
- It must be an array
- Every object must have 2 and only 2 properties (required).
code_name
, anddescription
code_name
must be unique inside that JSON array
Does Laravel has some out of the box feature for this? or do I need to manually decode the json on create and on update to validate that rules?
Till now. I only have this validation rules in my Model:
/**
* The model validation rules.
*
* @var array
*/
public static $rules = [
'values' => 'required|json', // TO BE CHECKED (values validation (json schema) and setter)
];
But that's not enough.
Important: this is not a duplicate question to: Laravel: validate json object
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire