Determine if the provided value is a valid URL.

Usage: '<index>' => 'valid_url'

@param string $field
@param array  $input
@param null   $param

@return mixed
480526
protected function validate_valid_url($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        if (!filter_var($input[$field], FILTER_VALIDATE_URL)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
639656
public static function url(string $value):bool
    {
        $value = (string)$value;
        $valid = filter_var($value, FILTER_VALIDATE_URL);
        return $valid !== false;
    }
1130499
public function url($uri,$param=[])
    {
        $list=Lists::get();
        if($this->get_index($uri,$list)===false){
            $url=$uri;
        }else{
            $url=$this->return_rule($list,$param);
        }
        return urldecode($url);
    }
797375
public function validateUrl($attribute, $params)
    {
        $parentParentId = (null === $this->structure) ? 0 : (int)$this->structure->parent_id;
        $parentContextId = (null === $this->structure) ? 0 : (int)$this->structure->context_id;
        if (
            $this->slug != $this->oldSlug
            || $this->parentParentId !== $parentParentId
            || $this->parentContextId !== $parentContextId
        ) {
            $url = $this->compileUrl();
            $query = self::find()
                ->select('url')
                ->innerJoin(
                    BaseStructure::tableName(),
                    'model_id = ' . BaseStructure::tableName() . '.id'
                )
                ->where([
                    'language_id' => $this->language_id,
                    'context_id' => $this->parentContextId,
                    'url' => $url
                ]);
            if (false === $this->isNewRecord) {
                $query->andWhere(['not', ['model_id' => $this->model_id]]);
            }
            $isset = $query->scalar();
            if (false !== $isset) {
                $this->addError('slug', Yii::t(
                    'dotplant.entity.structure',
                    'Value \'{value}\' already in use, please, choose another!',
                    ['value' => $this->slug]
                ));
            }
            $this->url = $url;
        }
    }
755416
protected function validate_float($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        if (!filter_var($input[$field], FILTER_VALIDATE_FLOAT)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
1236769
protected function validate_valid_cc($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        $number = preg_replace('/\D/', '', $input[$field]);

        if (function_exists('mb_strlen')) {
            $number_length = mb_strlen($number);
        } else {
            $number_length = strlen($number);
        }


        /**
         * Bail out if $number_length is 0. 
         * This can be the case if a user has entered only alphabets
         * 
         * @since 1.5
         */
        if( $number_length == 0 ) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }


        $parity = $number_length % 2;

        $total = 0;

        for ($i = 0; $i < $number_length; ++$i) {
            $digit = $number[$i];

            if ($i % 2 == $parity) {
                $digit *= 2;

                if ($digit > 9) {
                    $digit -= 9;
                }
            }

            $total += $digit;
        }

        if ($total % 10 == 0) {
            return; // Valid
        }

        return array(
            'field' => $field,
            'value' => $input[$field],
            'rule' => __FUNCTION__,
            'param' => $param,
        );
    }
110541
protected function validate_valid_twitter($field, $input, $param = NULL)
    {
        if(!isset($input[$field]) || empty($input[$field]))
        {
            return;
        }
        $json_twitter = file_get_contents("http://twitter.com/users/username_available?username=".$input[$field]);
        
        $twitter_response = json_decode($json_twitter);
        if($twitter_response->reason != "taken"){
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param
            );
        }
    }
230316
private function check($value, $params) {

		if(true === is_string($value)) {

			if(true === $params[0]) {
				return filter_var($value, \FILTER_VALIDATE_URL) !== false;
			}
 			
 			$value = preg_replace('/^http(s):\/\//i', '', $value);
 			$value = 'http://' . $value;

 			return filter_var($value, \FILTER_VALIDATE_URL) !== false;
 		}

 		return false;
	}
794420
protected function validateDateFormat($field, $value, $params)
    {
        $parsed = \date_parse_from_format($params[0], $value);

        return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
    }
898773
public function checkRouteParam($param, $value)
    {
        if (!$this->route) {
            return false;
        }

        $paramValue = $this->route->parameter($param);

        // If the parameter value is an instance of Model class, we compare $value with the value of
        // its primary key.
        if (is_a($paramValue, Model::class)) {
            return $paramValue->{$paramValue->getKeyName()} == $value;
        }

        return $paramValue == $value;
    }
297751
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            
            $params = $params['0'];
            if (empty($params['dropbox_access_token']) || empty($params['dropbox_app_secret'])) {
                return false;
            }
            
            $client = m62Dropbox::getRemoteClient($params['dropbox_access_token'], $params['dropbox_app_secret']);
            $adapter = new m62Dropbox($client);
            
            $filesystem = new Remote($adapter);
            if (! $filesystem->getAdapter()->listContents()) {
                return false;
            }
            
            return true;
        } catch (\Exception $e) {
            
            $this->setErrorMessage($e->getMessage());
            return false;
        }
    }
202476
protected function validate_valid_ipv6($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        if (!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
736909
public function validate_url( $value, $options = null ) {
		if ( empty( $value ) ) {
			return $value;
		}

		if ( 'none' === pods_v( static::$type . '_format', $options ) ) {
			return $this->strip_html( $value, $options );
		}

		if ( is_array( $value ) ) {
			if ( isset( $value['scheme'] ) ) {
				$value = $this->build_url( $value, $options );
			} else {
				$value = @implode( '', $value );
			}
		}

		if ( false === strpos( $value, '://' ) && 0 !== strpos( $value, '//' ) ) {
			$value = 'http://' . $value;
		}

		$url = wp_parse_url( $value );

		if ( empty( $url ) || count( $url ) < 2 ) {
			$value = '';
		} else {
			$defaults = array(
				'scheme'   => 'http',
				'host'     => '',
				'port'     => '',
				'path'     => '/',
				'query'    => '',
				'fragment' => '',
			);

			$url = array_merge( $defaults, $url );

			if ( 'normal' === pods_v( static::$type . '_format', $options ) ) {
				$value = $this->build_url( $url, $options );
			} elseif ( 'no-www' === pods_v( static::$type . '_format', $options ) ) {
				if ( 0 === strpos( $url['host'], 'www.' ) ) {
					$url['host'] = substr( $url['host'], 4 );
				}

				$value = $this->build_url( $url, $options );
			} elseif ( 'force-www' === pods_v( static::$type . '_format', $options ) ) {
				if ( false !== strpos( $url['host'], '.' ) && false === strpos( $url['host'], 'www', 0 ) ) {
					$url['host'] = 'www.' . $url['host'];
				}

				$value = $this->build_url( $url, $options );
			} elseif ( 'no-http' === pods_v( static::$type . '_format', $options ) ) {
				$value = $this->build_url( $url, $options );
				$value = str_replace( trim( $url['scheme'] . '://', ':' ), '', $value );

				if ( '/' === $url['path'] ) {
					$value = trim( $value, '/' );
				}
			} elseif ( 'no-http-no-www' === pods_v( static::$type . '_format', $options ) ) {
				if ( 0 === strpos( $url['host'], 'www.' ) ) {
					$url['host'] = substr( $url['host'], 4 );
				}

				$value = $this->build_url( $url, $options );
				$value = str_replace( trim( $url['scheme'] . '://', ':' ), '', $value );

				if ( '/' === $url['path'] ) {
					$value = trim( $value, '/' );
				}
			} elseif ( 'no-http-force-www' === pods_v( static::$type . '_format', $options ) ) {
				if ( false !== strpos( $url['host'], '.' ) && false === strpos( $url['host'], 'www', 0 ) ) {
					$url['host'] = 'www.' . $url['host'];
				}

				$value = $this->build_url( $url, $options );
				$value = str_replace( trim( $url['scheme'] . '://', ':' ), '', $value );

				if ( '/' === $url['path'] ) {
					$value = trim( $value, '/' );
				}
			}//end if
		}//end if

		return $value;
	}
261602
protected function validate_date($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        $cdate1 = date('Y-m-d', strtotime($input[$field]));
        $cdate2 = date('Y-m-d H:i:s', strtotime($input[$field]));

        if ($cdate1 != $input[$field] && $cdate2 != $input[$field]) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
1060299
protected function validateBetween($field, $value, $params)
    {
        if (!\is_numeric($value)) {
            return false;
        }
        if (!isset($params[0]) || !\is_array($params[0]) || \count($params[0]) !== 2) {
            return false;
        }

        list($min, $max) = $params[0];

        return $this->validateMin($field, $value, [$min]) && $this->validateMax($field, $value, [$max]);
    }
792052
protected function validate_required_file($field, $input, $param = null)
      {
          if (!isset($input[$field])) {
              return;
          }

          if (is_array($input[$field]) && $input[$field]['error'] !== 4) {
              return;
          }

          return array(
              'field' => $field,
              'value' => $input[$field],
              'rule' => __FUNCTION__,
              'param' => $param,
          );
      }
623063
public static function find($param, $field = '*', $parameters = array()) {
	    if (empty($param)) {
	        return false;
        }
		$model = new static;
		if (is_numeric($param)) {
			$param = [$model->getKeyName() => $param];
		}
		if (!is_array($param) || !array_key_exists('where', $param)) {
			$param = [
				'where' => $param
			];
		}
		return static::query()
			->load($param)
			->select($field)
			->addBinding($parameters)
			->one();
	}