public function validate($value)
{
if (!$value) {
return true;
}
switch ($this->type) {
case 'min':
return strlen(trim($value)) >= $this->val1;
case 'max':
return strlen(trim($value)) <= $this->val1;
case 'range':
return strlen(trim($value)) >= $this->val1 && strlen(trim($value)) <= $this->val2;
}
}