Move common things into the model level validation
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
3997085faf
commit
24841a75d4
1 changed files with 6 additions and 8 deletions
|
@ -48,7 +48,11 @@ class CustomField extends Model
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $rules = [];
|
protected $rules = [
|
||||||
|
'name' => 'required|unique:custom_fields',
|
||||||
|
'element' => 'required','in:text,listbox,textarea,checkbox,radio',
|
||||||
|
'field_encrypted' => 'nullable|boolean',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
|
@ -357,15 +361,9 @@ class CustomField extends Model
|
||||||
public function validationRules($regex_format = null)
|
public function validationRules($regex_format = null)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => 'required|unique:custom_fields',
|
|
||||||
'element' => [
|
|
||||||
'required',
|
|
||||||
Rule::in(['text', 'listbox', 'textarea', 'checkbox', 'radio']),
|
|
||||||
],
|
|
||||||
'format' => [
|
'format' => [
|
||||||
Rule::in(array_merge(array_keys(self::PREDEFINED_FORMATS), self::PREDEFINED_FORMATS, [$regex_format])),
|
Rule::in(array_merge(array_keys(self::PREDEFINED_FORMATS), self::PREDEFINED_FORMATS, [$regex_format])),
|
||||||
],
|
]
|
||||||
'field_encrypted' => 'nullable|boolean',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue