public function validate($value)
    {
        $value = $this->convertLiterals($value);

        // All fields allow * as a valid value
        if ('*' === $value) {
            return true;
        }

        // You cannot have a range and a list at the same time
        if (strpos($value, ',') !== false && strpos($value, '-') !== false) {
            return false;
        }

        if (strpos($value, '/') !== false) {
            list($range, $step) = explode('/', $value);
            return $this->validate($range) && filter_var($step, FILTER_VALIDATE_INT);
        }

        if (strpos($value, '-') !== false) {
            if (substr_count($value, '-') > 1) {
                return false;
            }

            $chunks = explode('-', $value);
            $chunks[0] = $this->convertLiterals($chunks[0]);
            $chunks[1] = $this->convertLiterals($chunks[1]);

            if ('*' == $chunks[0] || '*' == $chunks[1]) {
                return false;
            }

            return $this->validate($chunks[0]) && $this->validate($chunks[1]);
        }

        // Validate each chunk of a list individually
        if (strpos($value, ',') !== false) {
            foreach (explode(',', $value) as $listItem) {
                if (!$this->validate($listItem)) {
                    return false;
                }
            }
            return true;
        }

        // We should have a numeric by now, so coerce this into an integer
        if (filter_var($value, FILTER_VALIDATE_INT) !== false) {
            $value = (int) $value;
        }

        return in_array($value, $this->fullRange, true);
    }
public function validate($value)
    {
        $value = $this->convertLiterals($value);

        // All fields allow * as a valid value
        if ('*' === $value) {
            return true;
        }

        // You cannot have a range and a list at the same time
        if (strpos($value, ',') !== false && strpos($value, '-') !== false) {
            return false;
        }

        if (strpos($value, '/') !== false) {
            list($range, $step) = explode('/', $value);
            return $this->validate($range) && filter_var($step, FILTER_VALIDATE_INT);
        }

        if (strpos($value, '-') !== false) {
            if (substr_count($value, '-') > 1) {
                return false;
            }

            $chunks = explode('-', $value);
            $chunks[0] = $this->convertLiterals($chunks[0]);
            $chunks[1] = $this->convertLiterals($chunks[1]);

            if ('*' == $chunks[0] || '*' == $chunks[1]) {
                return false;
            }

            return $this->validate($chunks[0]) && $this->validate($chunks[1]);
        }

        // Validate each chunk of a list individually
        if (strpos($value, ',') !== false) {
            foreach (explode(',', $value) as $listItem) {
                if (!$this->validate($listItem)) {
                    return false;
                }
            }
            return true;
        }

        // We should have a numeric by now, so coerce this into an integer
        if (filter_var($value, FILTER_VALIDATE_INT) !== false) {
            $value = (int) $value;
        }

        return in_array($value, $this->fullRange, true);
    }
public function validate ( $ value ) { $ value = $ this -> convertLiterals ( $ value ) ; // All fields allow * as a valid value if ( '*' === $ value ) { return true ; } // You cannot have a range and a list at the same time if ( strpos ( $ value , ',' ) !== false && strpos ( $ value , '-' ) !== false ) { return false ; } if ( strpos ( $ value , '/' ) !== false ) { list ( $ range , $ step ) = explode ( '/' , $ value ) ; return $ this -> validate ( $ range ) && filter_var ( $ step , FILTER_VALIDATE_INT ) ; } if ( strpos ( $ value , '-' ) !== false ) { if ( substr_count ( $ value , '-' ) > 1 ) { return false ; } $ chunks = explode ( '-' , $ value ) ; $ chunks [ 0 ] = $ this -> convertLiterals ( $ chunks [ 0 ] ) ; $ chunks [ 1 ] = $ this -> convertLiterals ( $ chunks [ 1 ] ) ; if ( '*' == $ chunks [ 0 ] || '*' == $ chunks [ 1 ] ) { return false ; } return $ this -> validate ( $ chunks [ 0 ] ) && $ this -> validate ( $ chunks [ 1 ] ) ; } // Validate each chunk of a list individually if ( strpos ( $ value , ',' ) !== false ) { foreach ( explode ( ',' , $ value ) as $ listItem ) { if ( ! $ this -> validate ( $ listItem ) ) { return false ; } } return true ; } // We should have a numeric by now, so coerce this into an integer if ( filter_var ( $ value , FILTER_VALIDATE_INT ) !== false ) { $ value = ( int ) $ value ; } return in_array ( $ value , $ this -> fullRange , true ) ; }
Checks to see if a value is valid for the field

@param string $value
@return bool
Checks to see if a value is valid for the field