Changeset View
Changeset View
Standalone View
Standalone View
src/app/Rules/GroupName.php
- This file was copied to src/app/Rules/ResourceName.php.
Show All 35 Lines | class GroupName implements Rule | ||||
{ | { | ||||
if (empty($name) || !is_string($name)) { | if (empty($name) || !is_string($name)) { | ||||
$this->message = \trans('validation.nameinvalid'); | $this->message = \trans('validation.nameinvalid'); | ||||
return false; | return false; | ||||
} | } | ||||
// Check the max length, according to the database column length | // Check the max length, according to the database column length | ||||
if (strlen($name) > 191) { | if (strlen($name) > 191) { | ||||
$this->message = \trans('validation.nametoolong'); | $this->message = \trans('validation.max.string', ['max' => 191]); | ||||
return false; | return false; | ||||
} | } | ||||
// Check if the name is unique in the domain | // Check if the name is unique in the domain | ||||
// FIXME: Maybe just using the whole groups table would be faster than groups()? | // FIXME: Maybe just using the whole groups table would be faster than groups()? | ||||
$exists = $this->owner->groups() | $exists = $this->owner->groups() | ||||
->where('groups.name', $name) | ->where('groups.name', $name) | ||||
->where('groups.email', 'like', '%@' . $this->domain) | ->where('groups.email', 'like', '%@' . $this->domain) | ||||
Show All 20 Lines |