mirror of
https://github.com/archtechx/tenancy.git
synced 2026-06-21 09:24:03 +00:00
Consider null parameters invalid
Parameters passed to validateParameter should always be non-null, and if they're null, an exception is thrown.
This commit is contained in:
parent
fbffeb84b3
commit
48b8aac42d
3 changed files with 11 additions and 13 deletions
|
|
@ -50,20 +50,19 @@ trait ValidatesDatabaseParameters
|
|||
*
|
||||
* By default, only the characters in allowedParameterCharacters() are allowed.
|
||||
*
|
||||
* Null parameters are skipped.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function validateParameter(string|array|null $parameters, string|null $allowedCharacters = null): void
|
||||
{
|
||||
if ($parameters === null) {
|
||||
throw new InvalidArgumentException('Parameter cannot be null.');
|
||||
}
|
||||
|
||||
$allowedCharacters ??= $this->allowedParameterCharacters();
|
||||
|
||||
foreach (Arr::wrap($parameters) as $parameter) {
|
||||
if (is_null($parameter)) {
|
||||
// Skip if there's nothing to validate
|
||||
// (e.g. when $tenant->database()->getUsername() of an
|
||||
// improperly created tenant is null and it gets passed).
|
||||
continue;
|
||||
throw new InvalidArgumentException('Parameter cannot be null.');
|
||||
}
|
||||
|
||||
if (is_numeric($parameter)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue