Closed alberto-bottarini closed 3 years ago
This PR add the possibility to add custom validation rules to NestedForm instance.
I usually need a sort of "AvoidDuplicates" rule. Take this screenshot:
With this PR developers can create rules that validate the whole field, having access to all the nested properties.
Example has been implemented in this way:
//in Resource.php NestedForm::make('Addresses', 'addresses', Address::class) ->rules(new AvoidDuplicates)
//in Rules/AvoidDuplicates.php public function passes($attribute, $value) { //value is a multi-dimension array with all the nested-form properties $cities = array_column($value, 'city'); return count($cities) == count(array_unique($cities)); }
This PR add the possibility to add custom validation rules to NestedForm instance.
I usually need a sort of "AvoidDuplicates" rule. Take this screenshot:
With this PR developers can create rules that validate the whole field, having access to all the nested properties.
Example has been implemented in this way: