mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
(mvc) add basic validation to CSVListField type
This commit is contained in:
parent
fb2f4c3f5f
commit
c7aa31dedd
@ -54,6 +54,20 @@ class CSVListField extends BaseField
|
||||
*/
|
||||
private $selectOptions = array();
|
||||
|
||||
/**
|
||||
* @var string basic regex validation to use for the complete field
|
||||
*/
|
||||
protected $internalMask = '/^([\t\n\v\f\r 0-9a-zA-Z.,_\x{00A0}-\x{FFFF}])*/u';
|
||||
|
||||
/**
|
||||
* set validation mask
|
||||
* @param string $value regexp validation mask
|
||||
*/
|
||||
public function setMask($value)
|
||||
{
|
||||
$this->internalMask = $value ;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve data including selection options (from setSelectOptions)
|
||||
* @return array
|
||||
@ -107,10 +121,19 @@ class CSVListField extends BaseField
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array returns validators
|
||||
* @return array returns regex validator
|
||||
*/
|
||||
public function getValidators()
|
||||
{
|
||||
return array() ;
|
||||
if ($this->internalValidationMessage == null) {
|
||||
$msg = "list validation error" ;
|
||||
} else {
|
||||
$msg = $this->internalValidationMessage;
|
||||
}
|
||||
if (($this->internalIsRequired || $this->internalValue != null) && $this->internalMask != null) {
|
||||
return array(new Regex(array('message' => $msg,'pattern'=>trim($this->internalMask))));
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user