Returns an array of active price rules
@return array
351451
public function priceRule()
    {
        $options = array(
            'status' => 1,
            'order' => 'desc',
            'sort' => 'created',
            'limit' => array(0, $this->config->get('dashboard_limit', 10)));

        $items = $this->pricerule->getList($options);

        array_walk($items, function (&$item) {
            $item['value_formatted'] = $this->price->format($item['value'], $item['currency']);
        });

        return $items;
    }
933510
public function getMutualRules()
    {
        $rules = [];
        if (is_string($this->otherGuidAttribute)) {
            $rules = [
                [$this->otherGuidAttribute, 'required'],
                [$this->otherGuidAttribute, 'string', 'max' => 16],
            ];
        }
        return $rules;
    }
58228
public function getStatusRules()
    {
        if (!is_string($this->statusAttribute) || empty($this->statusAttribute)) {
            return [];
        }
        if (empty($this->statusRules)) {
            $this->statusRules = [
                [[$this->statusAttribute], 'required'],
                [[$this->statusAttribute], 'number', 'integerOnly' => true, 'min' => 0],
            ];
        }
        return $this->statusRules;
    }
1190947
public function getRuleList()
    {
        $rows = (new Query())
            ->select(['name'])
            ->from($this->manager->ruleTable)
            ->all();

        return ArrayHelper::map($rows, 'name', 'name');
    }
688294
protected function getRules()
    {
        $result = [];
        $relationNames = [];
        foreach ($this->relations as $key => $value) {
            $relationNames[] = is_array($value) ? $key : $value;
        }

        foreach ($this->owner->rules() as $key => $rule) {
            $attributes = is_array($rule[0]) ? $rule[0] : [$rule[0]];
            if (!$relations = array_intersect($relationNames, $attributes)) {
                continue;
            }
            $rule[0] = $relations;
            $result[$key] = $rule;
        }
        return $result;
    }
1255975
public function rules()
    {
        $attributes = [
            'title' => 'required',
            'text'  => 'required',
        ];

        $rules = $this->buildLocalizedRules($attributes);

        return array_merge($rules, [
            'id'           => 'exists:site_pages,id',
            'slug'         => 'required|alpha_dash|unique:site_pages,slug,'.$this->route('sites'),
            'published_at' => 'date',
            'concealed_at' => 'date',
        ]);
    }
155135
public function rules()
    {
        return array_merge(
            parent::rules(),
            $this->getPasswordHashRules(),
            $this->getPasswordResetTokenRules(),
            $this->getSourceRules(),
            $this->getStatusRules(),
            $this->getAuthKeyRules(),
            $this->getAccessTokenRules()
        );
    }
203815
protected function actionListPriceRule()
    {
        list($selected, $action, $value) = $this->getPostedAction();

        $deleted = $updated = 0;

        foreach ($selected as $rule_id) {

            if ($action === 'status' && $this->access('price_rule_edit')) {
                $updated += (int) $this->price_rule->update($rule_id, array('status' => $value));
            }

            if ($action === 'delete' && $this->access('price_rule_delete')) {
                $deleted += (int) $this->price_rule->delete($rule_id);
            }
        }

        if ($updated > 0) {
            $message = $this->text('Updated %num item(s)', array('%num' => $updated));
            $this->setMessage($message, 'success');
        }

        if ($deleted > 0) {
            $message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
            $this->setMessage($message, 'success');
        }
    }
106390
public function rules()
	{
		$args = func_get_args();

		$key = array_shift( $args );

		if ( !is_array( reset( $args ) ) )
		{
			$rules = $args;
		}
		else 
		{
			$rules = array_shift( $args );
		}

		$success = true;

		foreach( $rules as $rule )
		{
			$rule = explode( ':', $rule );
			$params = array();

			if ( array_key_exists( 1, $rule ) )
			{
				$params = explode( ',', $rule[1] );
			}

			$rule = reset( $rule );

			array_unshift( $params, $key );

			if ( !call_user_func_array( array( $this, $rule ), $params ) )
			{
				$success = false;
			}
		}

		return $success;
	}
892459
protected function rules() {
        return [
            new Rule('Transaction ID', function(array $subject) {
                $response = SubjectReader::readResponse($subject);

                return array_key_exists('id', $response);
            }, __('Checkout.com response does not have transaction ID.') ),

            new Rule('Associated Track ID', function(array $subject) {
                $paymentDO  = SubjectReader::readPayment($subject);
                $response   = SubjectReader::readResponse($subject);

                return $paymentDO->getOrder()->getOrderIncrementId() === $response['trackId'];
            }, __('Checkout.com track ID is not the same.') ),
        ];
    }
578694
public function rules()
    {
        $validationRule = [];
        $validationRule['name'] = 'required|max:255';

        if (null !== $this->request->get('dropdown-options')) {
            foreach ($this->request->get('dropdown-options') as $key => $val) {
                if ($key == '__RANDOM_STRING__') {
                    continue;
                }
                $validationRule['dropdown-options.' . $key . '.display_text'] = 'required';
            }
        }

        if ($this->getMethod() == 'POST') {
            $validationRule['identifier'] = 'required|max:255|alpha_dash|unique:attributes';
        }
        if ($this->getMethod() == 'PUT') {
            $validationRule['identifier'] = 'required|max:255|alpha_dash';
        }

        return $validationRule;
    }
1321808
public function rules()
    {
        $crude = CrudeInstance::get($this->crudeName);

        if ($crude == null)
            return [];

        if (! $crude instanceof \JanDolata\CrudeCRUD\Engine\Interfaces\WithValidationInterface)
            return [];

        $attr = $crude->getCrudeSetup()->getEditForm();

        return $crude->getValidationRules($attr, $this->all());
    }
113878
public function rules(): array
    {
        $user = $this->user($this->route('guard'));
        $user->updateRulesUniques();

        return $user->getRules();
    }
773998
public function rules() {

		$rules = [
			// Required, Safe
			[ [ 'firstName', 'lastName', 'email' ], 'required' ],
			[ 'phone', 'required', 'on' => [ 'phone', 'phone-captcha' ] ],
			// Text Limit
			[ [ 'email', 'phone' ], 'string', 'min' => 1, 'max' => Yii::$app->core->xLargeText ],
			// Other
			[ 'email', 'email' ]
		];

		if( empty( $this->captchaAction ) ) {

			$this->captchaAction	= '/cart/cart/captcha';
		}

		$rules[] = [ 'captcha', 'captcha', 'captchaAction' => $this->captchaAction, 'on' => [ 'captcha', 'phone-captcha' ] ];

		if( Yii::$app->core->trimFieldValue ) {

			$trim[] = [ [ 'firstName', 'lastName', 'email', 'phone' ], 'filter', 'filter' => 'trim', 'skipOnArray' => true ];

			return ArrayHelper::merge( $trim, $rules );
		}

		return $rules;
	}
347697
protected function getByPriceTypeASC() : array
    {
        $obPriceType = $this->getPriceTypeObject();
        if (empty($obPriceType)) {
            return $this->getByPriceASC();
        }

        //Get product ID list (sort by offer price)
        //We can not use groupBy() in this place
        $arElementIDList = (array) DB::table('lovata_shopaholic_prices')
            ->select('lovata_shopaholic_offers.product_id')
            ->where('lovata_shopaholic_prices.price_type_id', $obPriceType->id)
            ->where('lovata_shopaholic_offers.active', true)
            ->where('lovata_shopaholic_prices.item_type', Offer::class)
            ->orderBy('lovata_shopaholic_prices.price', 'asc')
            ->join('lovata_shopaholic_offers', 'lovata_shopaholic_offers.id', '=', 'lovata_shopaholic_prices.item_id')
            ->lists('product_id');
        $arElementIDList = array_unique($arElementIDList);

        return $arElementIDList;
    }
1107601
public function getIPRules()
    {
        $rules = [];
        if ($this->enableIP & static::$ipv4) {
            $rules = [
                [[$this->ipAttribute],
                    'string', 'max' => 4
                ],
            ];
        }
        if ($this->enableIP & static::$ipv6) {
            $rules = [
                [[$this->ipAttribute],
                    'string', 'max' => 16
                ],
            ];
        }
        if ($this->enableIP & static::$ipAll) {
            $rules[] = [
                [$this->ipTypeAttribute], 'in', 'range' => [IP::IPv4, IP::IPv6],
            ];
        }
        return $rules;
    }
416275
public function generateSearchRules()
    {
        if (($table = $this->getTableSchema()) === false) {
            return ["[['" . implode("', '", $this->getColumnNames()) . "'], 'safe']"];
        }
        $types = [];
        foreach ($table->columns as $column) {
            switch ($column->type) {
                case Schema::TYPE_SMALLINT:
                case Schema::TYPE_INTEGER:
                case Schema::TYPE_BIGINT:
                    $types['integer'][] = $column->name;
                    break;
                case Schema::TYPE_BOOLEAN:
                    $types['boolean'][] = $column->name;
                    break;
                case Schema::TYPE_FLOAT:
                case Schema::TYPE_DECIMAL:
                case Schema::TYPE_MONEY:
                    //$types['number'][] = $column->name;
                    //break;
                case Schema::TYPE_DATE:
                case Schema::TYPE_TIME:
                case Schema::TYPE_DATETIME:
                case Schema::TYPE_TIMESTAMP:
                default:
                    $types['safe'][] = $column->name;
                    break;
            }
        }   
		
        $rules = [];
        foreach ($types as $type => $columns) {            
            $sf = "";
            if ($type == "safe")
            {
				$tabs = $this->generateRelations();				
				foreach ($tabs as $tab)
				{
					if ($tab) {			
						$sf .= ($sf == ""?"/*, '":", '").$tab."Id'";
					}					
				}     					
				$sf .= ($sf == ""?"":"*/");
			}
			$rules[] = "[['" . implode("', '", $columns) . "'".$sf."], '$type']";
        }

        return $rules;
    }