mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
mvc: BooleanField validation message and faulty regex fix
This commit is contained in:
parent
3363fa9d2d
commit
cf80131910
@ -42,9 +42,12 @@ class BooleanField extends BaseField
|
||||
protected $internalIsContainer = false;
|
||||
|
||||
/**
|
||||
* @var string default validation message string
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $internalValidationMessage = "value should be a boolean (0,1)";
|
||||
protected function defaultValidationMessage()
|
||||
{
|
||||
return gettext('Value should be a boolean (0,1).');
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve field validators for this field type
|
||||
@ -52,13 +55,12 @@ class BooleanField extends BaseField
|
||||
*/
|
||||
public function getValidators()
|
||||
{
|
||||
// regexp for validating boolean values.
|
||||
$regex_mask = "/^([0,1]){1}$/";
|
||||
|
||||
$validators = parent::getValidators();
|
||||
if ($this->internalValue != null) {
|
||||
$validators[] = new Regex(array('message' => $this->internalValidationMessage,
|
||||
'pattern' => trim($regex_mask)));
|
||||
$validators[] = new Regex([
|
||||
'message' => $this->getValidationMessage(),
|
||||
'pattern' => '/^[01]$/',
|
||||
]);
|
||||
}
|
||||
return $validators;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user