Get rules associated with additional account attributes.
@return array rules.
434193
public function getAdditionalAccountRules()
    {
        $rules = $this->getEnableLoginAttributeRules();
        if ($this->getPasswordIsSeperate()) {
            $rules = array_merge($rules, $this->getPasswordHashRules());
        }
        return $rules;
    }
1215806
public function rules(): array
    {
        $user = $this->route('ability') ?? new Ability();
        $user->updateRulesUniques();
        $rules = $user->getRules();
        $rules['roles'] = 'nullable|array';

        return $rules;
    }
761540
public function rules()
    {
        return ArrayHelper::merge(parent::rules(), [
            // nickname rules
            'nicknameRequired' => ['nickname', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_CONNECT]],
            // email rules
            'emailRequired' => ['email', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER]],
            //mobile rules
            'mobileRequired' => ['mobile', 'required', 'on' => [self::SCENARIO_MOBILE_REGISTER]],
            // password rules
            'passwordRequired' => ['password', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_MOBILE_REGISTER]],
            // tags rules
            'tags' => ['tagValues', 'safe'],

            'transfer_balance' => ['transfer_balance', 'number'],
            'balance' => ['balance', 'number'],
        ]);
    }
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());
    }
325301
public function attributes()
    {
        $attributes = [];
        foreach ($this->rules() as $rule) {
            $names = reset($rule);
            if (is_string($names)) {
                $names = [$names];
            }
            foreach ($names as $name) {
                if (substr_compare($name, '!', 0, 1) === 0) {
                    $name = mb_substr($name, 1);
                }
                $attributes[$name] = $name;
            }
        }

        return array_values($attributes);
    }
1121746
protected function rulesForBody()
    {
        return [
            'name' => 'required',
            'description' => 'required',
            'cost' => 'required|numeric|max:999999999',
            'price' => 'required|numeric|max:999999999',
            'brand' => 'required',
            'stock' => 'required|integer',
            'low_stock' => 'required|integer',
            'status' => 'required|boolean',

            'category' => [
                'required',
                Rule::exists('categories', 'id')->where('id', $this->request->get('category')),
            ],

            'condition' => [
                'required',
                Rule::in(Attributes::make('condition')->keys()),
            ],

        ];
    }
1129022
public function rules()
    {
        return [
            'name' => [
                'required',
                'string',
                'between:3,255',
                'regex:/^[\w\s\.\,\-\_]+$/u',
            ],
            'email' => [
                'required',
                'email',
                'between:6,255',
                'unique:users,email' . (isset($this->user->id) ? ','.$this->user->id.',id' : ''),
            ],
            'password' => [
                'string',
                'between:6,255',
                'confirmed',
                isset($this->user->id) ? 'nullable' : 'required',
            ],
            'role' => [
                'sometimes',
                'required',
                'string',
                'max:255',
                'in:' . implode(',', cache('roles')),
            ],
            'where_from' => [
                'nullable',
                'string',
                'max:255',
                'alpha_num',
            ],
            'info' => [
                'nullable',
                'string',
                'max:500',
                'regex:/^[\w\s\.\,\-\_\?\!\r\n]+$/u',
            ],
            'avatar' => [
                'nullable',
                'image',
                'mimes:png,jpg,jpeg,gif,bmp',
                'max:800',
                'dimensions:max_width='.setting('users.avatar_max_width', 140).',max_height='.setting('users.avatar_max_height', 140),
            ],
        ];
    }
1308195
protected function getTermRules()
    {
        $rules = [];

        foreach ($this->repository as $field) {
            $rules[$field->getName()] = $field->getOption('rules');
        }

        return $rules;
    }
620714
public function rules(): array
    {
        $event = $this->route('event') ?? app('cortex.bookings.event');
        $event->updateRulesUniques();

        return array_merge($event->getRules(), [
            'duration' => 'required',
        ]);
    }
632149
protected function getUserRules()
    {
        $rules = [];

        foreach ($this->repository->all() as $field) {
            $rules[$field->getName()] = $field->getOption('rules');
        }

        return $rules;
    }
688670
public function getDescriptionRules()
    {
        $rules = [];
        if (is_string($this->descriptionAttribute) && !empty($this->descriptionAttribute)) {
            $rules[] = [
                [$this->descriptionAttribute],
                'string'
            ];
            $rules[] = [
                [$this->descriptionAttribute],
                'default',
                'value' => $this->initDescription,
            ];
        }
        return $rules;
    }
757717
public function rules(): array
    {
        $guardian = $this->route('guardian') ?? app('cortex.auth.guardian');
        $guardian->updateRulesUniques();
        $rules = $guardian->getRules();

        $rules['password'] = $guardian->exists
            ? 'confirmed|min:'.config('cortex.auth.password_min_chars')
            : 'required|confirmed|min:'.config('cortex.auth.password_min_chars');

        return $rules;
    }
803578
public function parse( $rules ) {
		$attributes = [];

		$rules = $this->parser->parse( $rules );

		foreach ( $rules as list( $rule, $parameters ) ) {
			$rule = strtolower( $rule );

			if ( method_exists( $this, $rule ) ) {
				$attributes += $this->$rule( $parameters );
			}
		}

		return $attributes;
	}
709976
public function rules()
    {
        $rules = $this->filterRules(array_merge([
            [['username', 'password'], 'trim'],
            [['username', 'password'], 'required'],
            ['rememberMe', 'boolean'],
            ['password', 'authenticate'],
        ], $this->rulesAddScenario(parent::rules(), 'reset')));

        return $rules;
    }
268630
public function getRules()
    {
        if (!$this->rules) {
            return 'return [];';
        }

        $parser = new SchemaParser($this->rules);

        $results = 'return ['.PHP_EOL;

        foreach ($parser->toArray() as $field => $rules) {
            $results .= $this->createRules($field, $rules);
        }

        $results .= "\t\t];";

        return $results;
    }
302947
protected function getRules()
    {
        if ($this->rules instanceof \Closure) {
            return $this->rules->call($this, $this->form);
        }

        return $this->rules;
    }
938146
public function getValidationRules()
    {
        $rules = [];

        foreach ($this->rules as $name => $rule) {
            $ruleName         = sprintf('2fa.*.settings.%s', $name);
            $rules[$ruleName] = $rule;
        }

        return $rules;
    }