添加验证规则

@param $params
@return $this
330237
public function rule(array $params)
    {
        if (isset($params['message'])) {
            $message = $params['message'];
            unset($params['message']);
        } else {
            $message = static::getRuleMessage($params[0]);
        }
        $this->_validations[] = [
            'rule' => $params[0],
            'attributes' => (array)$params[1],
            'params' => array_slice($params, 2),
            'message' => $message
        ];
        return $this;
    }
707395
public function params($params = null)
    {
        if (null !== $params) {
            $this->params = $params;

            return $this;
        }

        return $this->params;
    }
318595
public function setParams($params)
		{
			$this->params = [];
			foreach ($params as $param)
			{
				// variables
				$name = $param['name'];
				$type = $param['type'];
				$value = $param['value'];

				// properties
				$this->params[$name] = $this->convert($type, $value);
			}

			// return
			return $this;
		}
998598
public function not(array $params)
    {
        foreach ($params as $columnName => $value) {
            $this->addCondition('notEqualTo', [$columnName, $value]);
        }
        return $this;
    }
798571
public function setParams(array $params = array())
    {
        foreach ($params as $key => $value) {
            if (null != $value) {
                $this->$key = $value;
            }
        }

        return $this;
    }
798721
public function mergeParams($params)
    {
        foreach ($params as $k => $v) {
            if (is_int($k)) {
                $this->positionParams[] = $v;
            } else {
                $this->params[$k] = $v;
            }
        }

        return $this;
    }
10321
public function bind($params = null)
    {

        if (is_array($params)) {
            foreach ($params as $k => $v) {
                $this->bindParam($k, $v);
            }
        }

        return $this;
    }
361314
public function open(array $params = array())
	{
		$url = $this->getAbsoluteUrl($params);

		if ( !$url ) {
			throw new PageException('Page url not specified', PageException::TYPE_EMPTY_URL);
		}

		$this->pageFactory->getSession()->visit($url);

		return $this;
	}
1184443
public function add($params) {
		OpenpayConsole::trace('OpenpayApiDerivedResource @add');
		
		// TODO: validate call when the parent has not a valid ID
		$resource = parent::_create($this->resourceName, $params, array('parent' => $this));
		$this->addResource($resource);
		return $resource;
	}
930026
public function setParams($params)
    {
        if (!is_array($params) && !is_object($params)) {
            throw new Exception\InvalidArgumentException(
                sprintf('Event parameters must be an array or object; received "%s"', gettype($params))
            );
        }

        foreach ($params as $name => $value) {
            $this->setParam($name, $value);
        }

        return $this;
    }
253618
public function setSiteParameters($params)
    {
        foreach ($params as $key => $param) {
            $this->setSiteParameter($key, $param);
        }

        return $this;
    }
729009
public function withDictParams($params)
    {
        foreach ($params as $key => $value) {
            $this->withParam($key, $value);
        }

        return $this;
    }
1103719
public function prepareRequest($params = 'default')
    {
        if (is_string($params)) {
            // 载入请求模板
            $params = RequestTemplate::loadTemplate($this->getModule(), $this->getAction(), $params);
        } elseif ( ! is_array($params)) {
            $params = array();
        }

        $params['apiKey'] = isset($params['apiKey']) ? $params['apiKey'] : Config::get('API_KEY');
        $params['apiUser'] = isset($params['apiUser']) ? $params['apiUser'] : Config::get('API_USER');
        $this->data = $params;

        return $this;
    }
870098
public function create($method, $params)
    {
        if (strtolower($method) == 'get') {
            $this->get = $params;
        } else {
            $this->post = $params;
        }
        return $this;
    }
471132
public function withPost(array $params)
    {
        $request = $this;
        if ($this->isJson()) {
            $body = json_encode($params);
        } else {
            $body = http_build_query($params);
            if (!$this->hasHeader('Content-Type')) {
                $request = $this->withHeader('Content-Type', 'application/x-www-form-urlencoded');
            }
        }

        return new self(
            $request->getMethod(),
            $request->getUri(),
            $request->getHeaders(),
            $body,
            $request->getProtocolVersion(),
            $request->getRetries(),
            $request->getOptions(),
            $this->getServiceKey(),
            $this->getRequestKey()
        );
    }
1294664
public static function load($params = null)
    {
        if (!isset(self::$_instance)) {
            self::$_instance = new Email($params);
        }

        return self::$_instance;
    }
1233507
public function setParameters(array $params): self
    {
        foreach ($params as $key => $value) {
            $this->parameters[$key] = $value;
        }
        return $this;
    }