Get the rules associated with content to be blamed.
@return array rules.
975828
public function getBlameableRules()
    {
        $cache = $this->getCache();
        if ($cache) {
            $this->blameableLocalRules = $cache->get($this->getBlameableRulesCacheKey());
        }
        // 若当前规则不为空，且是数组，则认为是规则数组，直接返回。
        if (!empty($this->blameableLocalRules) && is_array($this->blameableLocalRules)) {
            return $this->blameableLocalRules;
        }

        // 父类规则与确认规则合并。
        if ($cache) {
            TagDependency::invalidate($cache, [$this->getEntityRulesCacheTag()]);
        }
        $rules = array_merge(
            parent::rules(),
            $this->getConfirmationRules(),
            $this->getBlameableAttributeRules(),
            $this->getDescriptionRules(),
            $this->getContentRules(),
            $this->getSelfBlameableRules()
        );
        $this->setBlameableRules($rules);
        return $this->blameableLocalRules;
    }
1135279
public function getRules()
	{
		$settings = $this->getSettings();
		if ($settings === false || !isset($settings->rules)) {
			throw new \Exception('Rule configuration not found');
		}
		return $settings->rules;
	}
697798
public function rules()
    {
        $admin_id = request('admin.id');
        $rules    = [
            'name'     => 'required|max:255',
            'email'    => "required|email|max:255|unique:admins,email,{$admin_id}",
            'password' => 'required|min:8|confirmed',
            'role_id'  => 'required',
        ];
        $rules = $this->mergeClientRules($rules);
        $rules = $this->checkForUpdate($rules);

        return $rules;
    }
1175039
protected function getRules()
    {
        if ($this->compiledRules === null) {
            $rules = array();
            foreach ($this->ruleFiles as $file) {
                $rules = array_merge(
                    $rules,
                    $this->parser->parse($file)
                );
            }

            $this->compiledRules = $this->compiler->compile($rules);
        }

        return $this->compiledRules;
    }
715180
public function getApiRules() {
        $rules = array();

        $allRules = $this->getRules();
        if (!is_array($allRules)) {
            $allRules = array();
        }
        $allRules = array_change_key_case($allRules, CASE_LOWER);

        $action = strtolower(DI()->request->getServiceAction()); 
        if (isset($allRules[$action]) && is_array($allRules[$action])) {
            $rules = $allRules[$action];
        }

        if (isset($allRules['*'])) {
            $rules = array_merge($allRules['*'], $rules);
        }

        $apiCommonRules = DI()->config->get('app.apiCommonRules', array());
        if (!empty($apiCommonRules) && is_array($apiCommonRules)) {
            // fixed issue #22
            if ($this->isServiceWhitelist()) {
                foreach ($apiCommonRules as &$ruleRef) {
                    $ruleRef['require'] = false;
                }
            }

            $rules = array_merge($apiCommonRules, $rules);
        }

        return $rules;
    }
290528
public static function rules()
    {
        if (self::$adminRules === null) {
            self::$adminRules = array();

            // Map over the array calling add_rule_for_controller on each
            $classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY);
            array_map(array(__CLASS__, 'add_rule_for_controller'), $classes);
        }
        return self::$adminRules;
    }
835268
public function rules()
    {

        $allowed_registration = implode(',', Seat::$options['registration']);
        $allowed_cleanup = implode(',', Seat::$options['cleanup_data']);
        $allowed_tracking = implode(',', Seat::$options['allow_tracking']);

        return [
            'registration'   => 'required|in:' . $allowed_registration,
            'cleanup_data'   => 'required|in:' . $allowed_cleanup,
            'admin_contact'  => 'required|email',
            'allow_tracking' => 'required|in:' . $allowed_tracking,
        ];
    }
539018
public function getRule()
    {
        $rules = [];
        if ($this->isRequired()) {
            $rules[] = 'required';
        }
        if ($this->getValidations()) {
            $rules[] = $this->getValidations();
        }

        $rules = join('|', $rules);
        return $rules;
    }
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;
	}
476291
public function getValidatorMessages()
    {
        $messages = [];
        
        foreach ($this->owner->getValidatorRules() as $rule) {
            
            if ($rule->hasMessage()) {
                $messages[$rule->getType()] = $rule->getMessage();
            }
            
        }
        
        return $messages;
    }
527869
public function rules()
    {
        if (method_exists($this, 'sanitize')) {
            call_user_func([get_called_class(), 'sanitize']);
        }

        $action = explode('@', request()->route()->getActionName())[1];

        if (method_exists($this, $action)) {
            return call_user_func([get_called_class(), $action]);
        }

        return [];
    }
933510
public function getMutualRules()
    {
        $rules = [];
        if (is_string($this->otherGuidAttribute)) {
            $rules = [
                [$this->otherGuidAttribute, 'required'],
                [$this->otherGuidAttribute, 'string', 'max' => 16],
            ];
        }
        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;
    }
739434
public function rules()
    {
        return [
            'title' => 'required|max:255|' . Rule::unique('laramanager_navigation_sections', 'title')->ignore($this->segment(3)),
            'icon' => 'required|max:255|' . Rule::unique('laramanager_navigation_sections', 'icon')->ignore($this->segment(3)),
            'ordinal' => 'required|integer|max:100'
        ];
    }
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 ?? [];
    }
302947
protected function getRules()
    {
        if ($this->rules instanceof \Closure) {
            return $this->rules->call($this, $this->form);
        }

        return $this->rules;
    }
223982
public function rules(): array
    {
        $admin = $this->route('admin') ?? app('cortex.auth.admin');
        $admin->updateRulesUniques();
        $rules = $admin->getRules();

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

        return $this->isMethod('POST') ? $rules : [];
    }