Constraint_length::validate PHP Method

validate() public method

public validate ( $value )
    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;
        }
    }