Add custom message for form's regex validation

This commit is contained in:
Sukhwinder Dhillon 2022-10-05 10:49:58 +02:00 committed by Johannes Meyer
parent 94f5bd75ac
commit 174abea6bd
2 changed files with 24 additions and 10 deletions

View file

@ -23,12 +23,19 @@ class BpConfigForm extends BpConfigBaseForm
'max' => 40
)
),
array(
[
'validator' => 'Regex',
'options' => array(
'pattern' => '/^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*)?[a-zA-Z0-9_]$/'
)
'options' => [
'pattern' => '/^[a-zA-Z0-9](?:[\w\h._-]*)?\w$/',
'messages' => [
'regexNotMatch' => $this->translate(
'Id must only consist of alphanumeric characters.'
. ' Underscore at the beginning and space, dot and hyphen at the beginning'
. ' and end are not allowed.'
)
]
]
]
),
'description' => $this->translate(
'This is the unique identifier of this process'

View file

@ -49,12 +49,19 @@ class BpUploadForm extends BpConfigBaseForm
'max' => 40
)
),
array(
[
'validator' => 'Regex',
'options' => array(
'pattern' => '/^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*)?[a-zA-Z0-9_]$/'
)
'options' => [
'pattern' => '/^[a-zA-Z0-9](?:[\w\h._-]*)?\w$/',
'messages' => [
'regexNotMatch' => $this->translate(
'Id must only consist of alphanumeric characters.'
. ' Underscore at the beginning and space, dot and hyphen at the beginning'
. ' and end are not allowed.'
)
]
]
]
),
));