diff --git a/app/Validation/DatabaseRules.php b/app/Validation/DatabaseRules.php index f09c8eb7..1fd8bb39 100644 --- a/app/Validation/DatabaseRules.php +++ b/app/Validation/DatabaseRules.php @@ -87,6 +87,17 @@ public function is_unique_compositely( return false; } + $essential_parameters = explode(":", $parameters[0]); + if ( + count($essential_parameters) < 2 + || !(model($essential_parameters[0]) instanceof BaseResourceModel) + || !in_array($essential_parameters[1], model($essential_parameters[0])->allowedFields) + ) { + $error = 'A model name and column name of the existing value is required' + .' in "{0}" to check if the value in {field} is unique.'; + return false; + } + return true; } }