Commit c7aa31de authored by Ad Schellevis's avatar Ad Schellevis

(mvc) add basic validation to CSVListField type

parent fb2f4c3f
......@@ -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();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment