Get the validation rules that apply to the request.

@return array
965665
public function rules()
    {
        $rules = [];

        if (($module = app('scaffold.module')) && $module instanceof Validable) {
            $rules = $module->rules();

            if (is_object($key = \Route::input('id')) && method_exists($key, 'getKey')) {
                $key = $key->getKey();
            }

            if (is_callable($rules)) {
                return $rules($key);
            }

            $rules = array_map(function ($rule) use ($key) {
                if (is_callable($rule)) {
                    $rule = $rule($key);
                }

                return $rule;
            }, $rules);
        }

        return $rules;
    }
631445
public function rules()
    {

        $name = $this->route()->getName();
        $tbl = ( str_contains($name, 'role') ) ? 'roles' : 'permissions';

       return [
            'name' => 'required|unique:'.$tbl.'|max:255|min:4',
            'slug' => 'required|unique:'.$tbl.'|max:255|min:4',
        ];

    }
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;
	}
1107334
public function rules()
    {
        $redirect = $this->route('seo_redirect');

        return [
            'old_url' => ['required', 'string', $this->getOldUrlRule()->ignore($redirect->id)],
            'new_url' => ['required', 'string'],
            'status'  => $this->getStatusRule(),
        ];
    }
459318
public function rules()
    {
        $config = app('scaffold.config');

        $identity = $config->get('auth.identity', 'username');
        $credential = $config->get('auth.credential', 'password');

        return [
            $identity => 'required',
            $credential => 'required',
        ];
    }
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;
    }
255265
protected function _getValidationRules() {
		$language = (string)Configure::read('Config.language');
		$cachePath = 'validation_rules_' . $language;
		$cached = Cache::read($cachePath, CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB);
		if ($cached !== false) {
			return $cached;
		}

		$result = $this->_getLocalFieldsValidationRules();
		$result += $this->_getLdapFieldsValidationRules();
		Cache::write($cachePath, $result, CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB);

		return $result;
	}
972956
public function rules()
    {
        /** @var  \Arcanesoft\Contracts\Auth\Models\User  $user */
        $user = $this->route('auth_user');

        return array_merge(parent::rules(), [
            'username'              => ['required', 'string', 'min:3', $this->getUsernameRule()->ignore($user->id)],
            'email'                 => ['required', 'string', 'email', $this->getEmailRule()->ignore($user->id)],
            'password'              => ['nullable', 'string', 'required_with:password_confirmation', 'min:8', 'confirmed'],
            'password_confirmation' => ['nullable', 'string', 'required_with:password'],
        ]);
    }
1222545
public function validationRules():array
    {
        $rules = [];

        foreach ($this as $control) {
            $rule = $control->getRule();
            if (!empty($rule)) {
                $rules[$control->getName()] = $control->getRule();
            }
        }

        return $rules;
    }
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 ?? [];
    }
1255122
public function getRules()
    {
        $rules = [
            static::FIRST_NAME => "required|max:100",
            static::LAST_NAME => "required|max:100",
            static::EMAIL => "required|max:100|email|unique:users,email,{$this->id},id",
        ];
        if (!$this->id) {
            $rules[static::PWD_FIELD] = 'required|min:' . config('app.model.user.password.min', 6)
                . '|max:' . config('app.model.user.password.max', 20);
        }
        return $rules;
    }
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()),
            ],

        ];
    }
539018
public function getRule()
    {
        $rules = [];
        if ($this->isRequired()) {
            $rules[] = 'required';
        }
        if ($this->getValidations()) {
            $rules[] = $this->getValidations();
        }

        $rules = join('|', $rules);
        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;
    }
9193
protected function getValidationRules(): array
    {
        return [
            QueryComplexity::class => new QueryComplexity(config('lighthouse.security.max_query_complexity', 0)),
            QueryDepth::class => new QueryDepth(config('lighthouse.security.max_query_depth', 0)),
            DisableIntrospection::class => new DisableIntrospection(config('lighthouse.security.disable_introspection', false)),
        ];
    }
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;
	}
1018072
public function validated(): array
    {
        $rules = $this->container->call([$this, 'rules']);

        return $this->only(collect($rules)->keys()->map(function ($rule) {
            return str_contains($rule, '.') ? explode('.', $rule)[0] : $rule;
        })->unique()->toArray());
    }