Maps data from database to rule values.

@return \Netgen\BlockManager\Persistence\Values\LayoutResolver\Rule[]
177772
public function mapRules(array $data): array
    {
        $rules = [];

        foreach ($data as $dataItem) {
            $rules[] = Rule::fromArray(
                [
                    'id' => (int) $dataItem['id'],
                    'status' => (int) $dataItem['status'],
                    'layoutId' => $dataItem['layout_id'] !== null ? (int) $dataItem['layout_id'] : null,
                    'enabled' => (bool) $dataItem['enabled'],
                    'priority' => (int) $dataItem['priority'],
                    'comment' => $dataItem['comment'],
                ]
            );
        }

        return $rules;
    }
1031543
public function rules() {
		$args = array();

		foreach ( $this->rules as $arg => $validation ) {
			if ( ! $validation || ! is_string( $validation ) ) {
				continue;
			}

			$args[ $arg ] = $this->parse_validation( $validation );
		}

		return $args;
	}
1058030
public function getValidationRules()
    {
        $rules = $this->getOption('rules', []);
        $name = $this->getNameKey();
        $messages = $this->getOption('error_messages', []);
        $formName = $this->formHelper->transformToDotSyntax($this->parent->getName());

        if ($messages && $formName) {
            $newMessages = [];
            foreach ($messages as $messageKey => $message) {
                $messageKey = sprintf('%s.%s', $formName, $messageKey);
                $newMessages[$messageKey] = $message;
            }
            $messages = $newMessages;
        }

        if (!$rules) {
            return (new Rules([]))->setFieldName($this->getNameKey());
        }

        if (is_array($rules)) {
            $rules = array_map(function ($rule) use ($name) {
                if ($rule instanceof \Closure) {
                    return $rule($name);
                }

                return $rule;
            }, $rules);
        }

        return (new Rules(
            [$name => $rules],
            [$name => $this->getOption('label')],
            $messages
        ))->setFieldName($this->getNameKey());
    }
1356495
private function getRuleSelectQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT r.*', 'rd.*')
            ->from('ngbm_rule', 'r')
            ->innerJoin(
                'r',
                'ngbm_rule_data',
                'rd',
                $query->expr()->eq('rd.rule_id', 'r.id')
            );

        return $query;
    }
155135
public function rules()
    {
        return array_merge(
            parent::rules(),
            $this->getPasswordHashRules(),
            $this->getPasswordResetTokenRules(),
            $this->getSourceRules(),
            $this->getStatusRules(),
            $this->getAuthKeyRules(),
            $this->getAccessTokenRules()
        );
    }
1030089
public function rules()
    {
        $modelManager = app(AdminManager::class)->getAdminInstance();
        $modelManager->find(\Route::current()->parameter('one'));

        return $modelManager->getUpdateRules();
    }
1287395
public function rules(): array
    {
        $manager = $this->route('manager') ?? app('cortex.auth.manager');

        // Attach attribute rules
        $manager->getEntityAttributes()->each(function ($attribute, $attributeName) use (&$rules) {
            switch ($attribute->type) {
                case 'datetime':
                    $type = 'date';
                    break;
                case 'text':
                case 'check':
                case 'select':
                case 'varchar':
                    $type = 'string';
                    break;
                default:
                    $type = $attribute->type;
                    break;
            }

            $rule = ($attribute->is_required ? 'required|' : 'nullable|').$type;
            $rules[$attributeName.($attribute->is_collection ? '.*' : '')] = $rule;
        });

        return $rules ?? [];
    }
674871
public function rules(): array
    {
        $languages = TransHelper::getAllLanguages();
        $category = $this->route('category');

        $rules = [
            'icons.*' => 'image|max:4096',
        ];

        foreach ($languages as $language) {

            $translationInstance = null;
            $iso = $language->iso_code;

            if ($category) {
                $translationInstance = $category->translations()->where('locale', $language->iso_code)->first();
            }

            // Name
            $rules["translations.{$iso}.name"] = 'required';

            // Slug
            $uniqueSlug = Rule::unique('netcore_category__category_translations', 'slug')->ignore(
                object_get($translationInstance, 'id')
            );

            $rules["translations.{$iso}.slug"][] = 'nullable';
            $rules["translations.{$iso}.slug"][] = $uniqueSlug;
        }

        return $rules;
    }
369194
public function getColumnObjectsMapping()
    {
        $mapping = [];
        $foreignTable = $this->getForeignTable();
        for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
            $mapping[] = [
                'local'   => $this->parentTable->getColumn($this->localColumns[$i]),
                'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]),
                'value' => $this->localValues[$i],
            ];
        }

        return $mapping;
    }
117411
public function getRules()
    {
        $this->defaultParams['format_positive'] = '%v%s';
        $this->defaultParams['format_negative'] = '-%v%s';

        return array(

            // Celsius
            'C' => array(
                'symbol' => '°C',
                'rate'   => function ($value, $ruleTo) {

                    if ($ruleTo === 'k') {
                        $value += 273.15;
                    } else {
                        $value -= 273.15;
                    }

                    return $value;
                },
            ),

            // Fahrenheit
            'F' => array(
                'symbol' => '°F',
                'rate'   => function ($value, $ruleTo) {

                    if ($ruleTo === 'k') {
                        $value = ($value + 459.67) * (5 / 9);
                    } else {
                        $value = $value * (9 / 5) - 459.67;
                    }

                    return $value;
                },
            ),

            // Rankine
            'R' => array(
                'symbol' => '°R',
                'rate'   => function ($value, $ruleTo) {

                    if ($ruleTo === 'k') {
                        $value = $value * 5 / 9;
                    } else {
                        $value = $value * 9 / 5;
                    }

                    return $value;
                },
            ),

            // Kelvin
            'K' => array(
                'symbol' => 'K',
                'rate'   => function ($value) {
                    return $value;
                },
            ),
        );
    }
861202
public function getIdRules()
    {
        if ($this->idAttribute == false) {
            return [];
        }
        if ($this->idAttributeSafe || $this->idAttributeType === static::$idTypeAutoIncrement) {
            return [
                [[$this->idAttribute], 'safe'],
            ];
        }
        if (is_string($this->idAttribute) && !empty($this->idAttribute) &&
            is_int($this->idAttributeLength) &&
            $this->idAttributeLength > 0) {
            $rules = [
                [[$this->idAttribute], 'required'],
                [[$this->idAttribute], 'unique'],
            ];
            if ($this->idAttributeType === static::$idTypeInteger) {
                $rules[] = [
                    [$this->idAttribute], 'number', 'integerOnly' => true
                ];
            }
            if ($this->idAttributeType === static::$idTypeString) {
                $rules[] = [[$this->idAttribute], 'string',
                    'max' => $this->idAttributeLength,];
            }
            return $rules;
        }
        return [];
    }
890182
public function getScenarios(): array
    {
        if ($this->scenario === null) {
            return $this->rules;
        }

        $rules = [];

        foreach ($this->rules as $rule) {
            if (! isset($rule['on']) && ! isset($rule['except'])) {
                $rules[] = $rule;
            } elseif (isset($rule['on']) && $this->matchScenario($rule['on'])) {
                unset($rule['on']);
                $rules[] = $rule;
            } elseif (isset($rule['except']) && $this->matchScenario($rule['except'])) {
                unset($rule['except']);
                $rules[] = $rule;
            }
        }

        return $rules;
    }
1266153
public function getRules()
    {
        if (!isset($this->ruleSet)) {
            $this->ruleSet = new PriorityList(RuleInterface::class);
        }
        return $this->ruleSet;
    }
52167
public function rules(): array
    {
        $user = $this->route('role') ?? new Role();
        $user->updateRulesUniques();
        $rules = $user->getRules();
        $rules['abilities'] = 'nullable|array';

        return $rules;
    }
265622
protected function _getRules() {
        $relation = $this->getRelation();
        $localModel = $relation->getLocalModel();

        $hasNameConflict = $relation->name === $localModel->id;
        if ($hasNameConflict) {
            return array($relation->name . '1', $relation->name . '2');
        }

        $modelIds = $this->_getModelIdsAlphabetically();

        $rules = array($relation->name, $this->_getSecondRule());
        $rules = $this->_sortRulesEgocentrically($rules);

        return $rules;
    }
779822
public function getRules()
    {
        if (!$this->rules) {
            return '[]';
        }
        $results = '[' . PHP_EOL;

        foreach ($this->getSchemaParser()->toArray() as $column => $value) {
            $results .= "\t\t'{$column}'\t=>'\t{$value}'," . PHP_EOL;
        }

        return $results . "\t" . ']';
    }
834212
public function getMappedSecondAttributes()
    {
        $attributes = [];

        /* Only the first array in data will be examined, and map its attributes to db attributes,
           the attributes that are not present, will not be included
        */
        if (is_array($this->data[0])) {
            foreach ($this->data[0] as $attribute => $attributeValue) {
                if (array_key_exists($attribute, $this->mappingFirstEntityToSecondEntityAttributes)) {
                    $attributes[$this->mappingFirstEntityToSecondEntityAttributes[$attribute]] = $attributeValue;
                }
            }
        }

        return $attributes;
    }