Skip to content

Commit

Permalink
internal(validation): check basic parameters for uniqueness exists
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 23, 2023
1 parent d387f5c commit 3d02e19
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Validation/DatabaseRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 3d02e19

Please sign in to comment.