validator youtube link

@param $attribute
@param $value
@param $parameters
@param $validator
@param $validator
@return bool
352244
public function validateVideoLink($attribute, $value, $parameters, $validator)
    {
        return preg_match($this->youtubeRegex, $value) || preg_match($this->vimeoRegex, $value);
    }
360369
protected function validateIsbn($attribute, $value, $parameters)
    {
        // Prepare value for validation
        $value = str_replace([' ', '-', '‐', '.'], '', $value);

        // Length of value
        $length = strlen($value);

        // Validate either ISBN10 or ISBN13
        if ($length == 10) {
            return $this->validateIsbn10($attribute, $value, $parameters);
        } elseif ($length == 13) {
            return $this->validateIsbn13($attribute, $value, $parameters);
        }

        return false;
    }
1155221
protected function validateDateFormat($attribute, $value, $parameters)
	{
		$parsed = date_parse_from_format($parameters[0], $value);

		return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
	}
417443
public function behaviorValidator($attribute, $params)
    {
        $behavior = $params['behavior'];
        $validator = $params['validator'];
        unset($params['behavior']);
        unset($params['validator']);
        if (($behavior = $this->getBehavior($behavior)) !== null) {
            return $behavior->{$validator}($attribute, $params);
        }

        return true;
    }
450554
public function validateUnique($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'unique');

        [$connection, $table] = $this->parseTable($parameters[0]);

        // The second parameter position holds the name of the column that needs to
        // be verified as unique. If this parameter isn't specified we will just
        // assume that this column to be verified shares the attribute's name.
        $column = $this->getQueryColumn($parameters, $attribute);

        [$idColumn, $id] = [null, null];

        if (isset($parameters[2])) {
            [$idColumn, $id] = $this->getUniqueIds($parameters);

            if (! is_null($id)) {
                $id = stripslashes($id);
            }
        }

        // The presence verifier is responsible for counting rows within this store
        // mechanism which might be a relational database or any other permanent
        // data store like Redis, etc. We will use it to determine uniqueness.
        $verifier = $this->getPresenceVerifierFor($connection);

        $extra = $this->getUniqueExtra($parameters);

        if ($this->currentRule instanceof Unique) {
            $extra = array_merge($extra, $this->currentRule->queryCallbacks());
        }

        return $verifier->getCount(
            $table, $column, $value, $id, $idColumn, $extra
        ) == 0;
    }
923412
protected function validateMax( $attribute, $value, $parameters )
	{
		$this->requireParameterCount( 1, $parameters, 'max' );

		if ( $value instanceof UploadedFile && !$value->isValid() )
		{
			return false;
		}

		return $this->getSize( $attribute, $value ) <= $parameters[0];
	}
788334
protected function validateIsbn10($attribute, $value, $parameters)
    {
        // Prepare value for validation
        $value = str_replace([' ', '-', '‐', '.'], '', $value);

        // Make sure value is exactly 10 characters
        //
        // Sometimes an ISBN10 number can end on an "X". Therefore we
        // only validate the first 9 characeters as numeric.
        if (strlen($value) != 10 || ! is_numeric(substr($value, -10, 9))) {
            return false;
        }

        // Grab "check digit" for later use
        // Also handle when "X" is the "check digit" instead of an integer
        $checkDigit = substr($value, -1);
        $checkDigit = (strtoupper($checkDigit) == 'X') ? 10 : $checkDigit;

        // Generate checksum
        $sum = 0;
        for ($i = 0; $i < 9; $i++) {
            $sum += ($value[$i] * (10 - $i));
        }

        // Add "check digit" to checksum
        $sum += $checkDigit;

        // Verify checksum
        return ($sum % 11) == 0;
    }
824244
protected function validateRequiredIf($attribute, $value, $parameters)
	{
		if ($parameters[1] == array_get($this->data, $parameters[0]))
		{
			return $this->validateRequired($attribute, $value);
		}

		return true;
	}
765797
public function validateElfinderMax($attribute, $value, $parameters, $validator)
    {
        $size = $parameters[0] * 1024; // parameters kB to B
        if ( File::size($value) > $size ) {
            return false;
        }
        return true;
    }
900408
public function validate(\Phalcon\Validation $validator, $attribute)
    {
        $value = $validator->getValue($attribute);

        if (!filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {

            $message = $this->getOption('message');
            if (!$message) {
                $message = 'The IP is not valid';
            }

            $validator->appendMessage(new Message($message, $attribute, 'Ip'));

            return false;
        }

        return true;
    }
696242
public function validateDateEquals($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'date_equals');

        return $this->compareDates($attribute, $value, $parameters, '=');
    }
1343485
public function validateMimetypes($attribute, $value, $parameters)
    {
        if (! $this->isValidFileInstance($value)) {
            return false;
        }

        if ($this->shouldBlockPhpUpload($value, $parameters)) {
            return false;
        }

        return $value->getPath() !== '' &&
                (in_array($value->getMimeType(), $parameters) ||
                 in_array(explode('/', $value->getMimeType())[0].'/*', $parameters));
    }
1263231
public function validateArrayWithAllOrNone($attribute, $value, $parameters)
    {
        $missing = 0;

        foreach ($parameters as $key) {
            if (!isset($value[$key])) {
                ++$missing;
            }
        }

        return $missing === count($parameters) || $missing === 0;
    }
381539
public function validateEmail($attribute, $value)
    {
        if (! is_string($value) && ! (is_object($value) && method_exists($value, '__toString'))) {
            return false;
        }

        return (new EmailValidator)->isValid($value, new RFCValidation);
    }
774198
public function validateEmptyWith($attribute, $value, $parameters)
    {
        $values = [];

        foreach ($parameters as $parameter) {
            $values[] = $this->getValue($parameter);
        }

        return Validator::isEmptyWith($value, $values);
    }
144836
protected function validateDigits($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'digits');

        return $this->validateNumeric($attribute, $value)
            && strlen((string) $value) == $parameters[0];
    }
420978
protected function validateFormatoCpfCnpj($attribute, $value)
    {
        return $this->validateFormatoCpf($attribute, $value) || $this->validateFormatoCnpj($attribute, $value);
    }