Determine if the given padding for a value is valid.

@param  string  $pad
@param  string  $value
@return bool
348636
protected function paddingIsValid($pad, $value)
    {
        $beforePad = strlen($value) - $pad;

        return substr($value, $beforePad) == str_repeat(substr($value, -1), $pad);
    }
1284183
public static function hasValidLength($value)
    {
        // Sanitize
        $value  = (int) $value;
        $length = strlen($value);

        // Validate
        return !($length < 9 || $length > 13);
    }
507361
protected function _validate($value)
    {
        $value = trim($value);
        $pattern = ComHashtagsDomainEntityHashtag::PATTERN_HASHTAG;

        return (is_string($value) && (preg_match($pattern, $value)) == 1);
    }
1089669
function pad(value, length) {
  value = String(value);
  length = length || 2;

  while (value.length < length) {
    value = '0' + value;
  }

  return value;
}
333365
public function isValid($value)
    {
        $this->_setValue($value);

        if (!$value || !is_string($value) && !is_int($value) && !is_float($value)) {
            $this->_error(self::INVALID_PRICE);
            return false;
        }

        if (false === $this->_options['negative'] && '-' === $value[0]) {
            $this->_error(self::PRICE_NEGATIVE, $value);
            return false;
        }

        $status = @preg_match($this->_pattern, $value);
        if (false === $status) {
            $this->_error(self::INVALID_PRICE);
            return false;
        }

        if (!$status) {
            $this->_error(self::INVALID_PRICE);
            return false;
        }

        return true;
    }
1319912
public function isValid($value)
    {
        $valueString = (string) $value;

        $this->_setValue($valueString);

        if (ip2long($valueString) === false) {
            $this->_error();
            return false;
        }

        return true;
    }
857229
public function isValid($value)
    {
        $this->_setValue($value);

        if (!is_string($value)) {
            return false;
        }

        return @preg_match(self::LASTMOD_REGEX, $value) == 1;
    }
604478
public function isValueValid($value) {
		return $value instanceof DataType\NumberType || $value instanceof Type\PriceSpecificationType || $value instanceof DataType\TextType;
	}
963206
public function valid ($value)
    {
        $valid = true;
        $error = array();

        if ($this->minLength !== null && ! (strlen($value) >= $this->minLength)) {
            $valid = false;
            $error[] = 'minimum length';
        }

        if ($this->maxLength !== null && ! (strlen($value) <= $this->maxLength)) {
            $valid = false;
            $error[] = 'maximum length';
        }

        // var_dump(array('cur' => $value, 'min' => $this->minValue));
        if ($this->minValue !== null && (! is_numeric($value) || ! ($value >= $this->minValue))) {
            $valid = false;
            $error[] = 'minimum value';
        }

        if ($this->maxValue !== null && (! is_numeric($value) || ! ($value <= $this->maxValue))) {
            $valid = false;
            $error[] = 'maximum value';
        }

        if ($this->startsWith !== null && ! (strpos($value, $this->startsWith) === 0)) {
            $valid = false;
            $error[] = 'starts with';
        }

        if ($this->endsWith !== null && ! (strpos($value, $this->endsWith) === strlen($value)-strlen($this->endsWith))) {
            $valid = false;
            $error[] = 'ends with';
        }

        if ($this->regex !== null && ! preg_match($this->regex, $value)) {
            $valid = false;
            $error[] = 'valid custom field';
        }

        if ($this->enum !== null && is_array($this->enum)) {
            if (! in_array($value, $this->enum)) {
                $valid = false;
                $error[] = 'is value of list';
            }
        }

        if ($this->valid !== null) {
            switch ($this->valid) {
                case 'email':
                    if (! filter_var($value, FILTER_VALIDATE_EMAIL))
                        $valid = false;
                    break;
                case 'url':
                    if (! filter_var($value, FILTER_VALIDATE_URL))
                        $valid = false;
                    break;
                default:
                    $valid = false;
            }
        }
        if (! $valid) {
            $error[] = 'valid \'' . $this->valid . '\'';
        }

        return $valid === true ? true : $error;
    }
10375
protected function checkValidity($value) : bool
    {
        if (preg_match(static::$regex, $value)) {
            return true;
        } elseif ('' === $value) {
            return true;
        } else {
            return false;
        }
    }
126896
public function isValid($value)
    {
        $this->setValue($value);

        $pattern = '/^[a-z0-9_\-]*[a-z0-9]$/i';

        $this->pageNameOk = true;

        if (!preg_match($pattern, $value)) {
            $this->error(self::PAGE_NAME);
            $this->pageNameOk = false;
        }

        return $this->pageNameOk;
    }
1260685
public function isValid($value)
    {
        $ok = true;
        
        if (!preg_match('/^[0-9]+(\.[0-9]+)?$/', $value)) {
            $this->error(self::SYNTAX);
            return false;
        }
        
        if ($value < $this->options['min']) {
            $this->error(self::MIN);
            $ok = false;
        }
        
        if ($value > $this->options['max']) {
            $this->error(self::MAX);
            $ok = false;
        }
        
        $parts = explode('.', $value);
        if (isset($parts[1]) && strlen($parts[1]) > $this->options['precision']) {
            if ($this->options['precision']) {
                $this->error(self::PRECISION);
            } else {
                $this->error(self::NO_COMMA);
            }
            $ok = false;
        }

        return $ok;
    }
1270623
public function validTagChars($value)
    {
        $success = (bool)preg_match('/^[a-z\d\s]+$/', $value);

        return $success ?: sprintf('%s: %s', I18N_ALLOWED_CHARS, I18N_LOWERCASE_NUMBERS_SPACE);
    }
785074
public function isValid ($value)
    {
        if (!is_numeric($value)) {
            $this->error(self::INVALID);
            return false;
        }

        if (!preg_match('/^-?[0-9]+([.,][0-9]+)?$/', $value)) {
            $this->error(self::INVALID);
            return false;
        }

        return true;
    }
679365
public function padBoth($length, $padStr = ' ')
    {
        $padding = $length - $this->getLength();
        return $this->applyPadding(floor($padding / 2), ceil($padding / 2), $padStr);
    }
728948
public function isValid($value)
    {
        if (!is_string($value)
            && !($value instanceof Uuid) // If instance of Uuid still does not means that is valid
        ) {
            $this->error(self::INVALID);
            return false;
        }

        $this->setValue($value);

        if (!preg_match('/^' . self::UUID_V4_PATTERN . '$/', $value)) {
            $this->error(self::NOT_UUID_V4);
            return false;
        }

        return true;
    }
183740
public function validate($value)
    {
        // generic pattern match if it's numeric [float/int/double]
        if (!preg_match('/^\d{0,}[.,]?\d*$/', (string)$value)) return false;

        $this->value = $value;

        return true;
    }