getMobileRules - Custom detection methods, only on mobile devices

@return    array    array(name => value, name => value, ...)
@example            array('Samsung', 'AndroidOS', 'Safari')
341233
public function getMobileRules()
    {
        $arrReturn = array();
        foreach($this->MobileDetect->getRules() as $name => $regex)
        {
            $check = $this->MobileDetect->{'is'.$name}();
            if($check)
            {
                array_push($arrReturn, $name);
            }
        }
        return $arrReturn;
    }
291529
protected function getValidationRules(): array
    {
        $validationRulesFromRepository = $this->repository->getModelValidationRules();

        return !empty($validationRulesFromRepository) ? $validationRulesFromRepository : $this->validationRules;
    }
1234902
protected static function detectDevice()
  {
    $detect = new MobileDetect();
    self::$detectCode = array();
    self::$detectCode['tablet'] = $detect->isTablet();
    self::$detectCode['mobile'] = $detect->isMobile() && !$detect->isTablet();
    self::$detectCode['desktop'] = !self::$detectCode['tablet'] && !self::$detectCode['mobile'];
    self::$detectCode['device'] = 'desktop';
    foreach ($detect->getRules() as $name => $regex) {
      if ($detect->{'is' . $name}()) {
        self::$detectCode['device'] = $name;
        break;
      }
    }
  }
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;
	}
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());
    }
476291
public function getValidatorMessages()
    {
        $messages = [];
        
        foreach ($this->owner->getValidatorRules() as $rule) {
            
            if ($rule->hasMessage()) {
                $messages[$rule->getType()] = $rule->getMessage();
            }
            
        }
        
        return $messages;
    }
196092
public function rules()
    {
        if ($this->parsedRules !== null) {
            return $this->parsedRules;
        }

        $rules = $this->buildRules();

        $this->callBeforeListeners('parseRules', [&$rules]);
        $rules = $this->parseRules($rules);
        $this->callAfterListeners('parseRules', [&$rules]);

        $this->parsedRules = $rules;

        return $this->parsedRules;
    }
985448
protected function getLayoutType() {
        $detector = new MobileDetect();
        $isMobile = $detector->isMobile();
        $isTablet = $detector->isTablet();
        unset($detector);

        return array('isMobile' => $isMobile, 'isTablet' => $isTablet, 'isDesktop' => (!$isMobile && !$isTablet));
    }
72235
public function getRules()
    {
        $this->defaultParams['num_decimals']    = 2;
        $this->defaultParams['num_decimals']    = 2;
        $this->defaultParams['round_type']      = Formatter::ROUND_CLASSIC;
        $this->defaultParams['decimal_sep']     = '.';
        $this->defaultParams['thousands_sep']   = ' ';
        $this->defaultParams['format_positive'] = '%v %s';
        $this->defaultParams['format_negative'] = '-%v %s';

        return array(
            'eur' => array(
                'symbol' => '€',
                'rate'   => 1,
            ),

            'usd' => array(
                'symbol'          => '$',
                'format_positive' => '%s%v',
                'format_negative' => '-%s%v',
                'rate'            => 0.5,
            ),

            'rub' => array(
                'symbol'      => 'руб.',
                'decimal_sep' => ',',
                'rate'        => 0.02,
            ),

            'uah' => array(
                'symbol'      => 'грн.',
                'decimal_sep' => ',',
                'rate'        => 0.04,
            ),

            'byr' => array(
                'symbol'       => 'Br',
                'round_type'   => Formatter::ROUND_CEIL,
                'round_value'  => '-2',
                'num_decimals' => '0',
                'rate'         => 0.00005,
            ),

            '%'   => array(
                'symbol'          => '%',
                'format_positive' => '%v%s',
                'format_negative' => '-%v%s',
            ),
        );
    }
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;
    }
789799
public static function getRules()
    {
        $rules = static::rules();

        if (RevyAdmin::isTranslationMode()) {
            $object = new static();

            foreach ($rules as $field => $rule) {
                if ($object->isTranslatableField($field)) {
                    unset($rules[$field]);
                    foreach (Language::getLocales() as $locale) {
                        $rules[RevyAdmin::getTranslationFieldName($field, $locale)] = $rule;
                    }
                }
            }
        }
      
        return $rules;
    }
972605
protected function checkBrowserAndroidSamsungGalaxy() 
    {
	    if( stripos($this->_agent,'Android') !== false ) 
	    {
	        $this->setVersion(self::VERSION_UNKNOWN);
	        $this->setMobile(true);
	        
	    	if( stripos($this->_agent,'GT-I9000') !== false ) 
	    	{
    		    $this->setBrowser(self::BROWSER_GALAXY_S);
			    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9001') !== false ) 
	    	{
			    $this->setBrowser(self::BROWSER_GALAXY_S_PLUS);
			    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9100') !== false ) 
	    	{
			    $this->setBrowser(self::BROWSER_GALAXY_S_II);
			    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9300') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S_III);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I8190') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S_III_MINI);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9301') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S_III_NEO);
	    	    return true;
	    	}
	    	//S4
	    	if( stripos($this->_agent,'GT-I9500') !== false ||
	    	    stripos($this->_agent,'GT-I9505') !== false ||
	    	    stripos($this->_agent,'GT-I9506') !== false ||
	    	    stripos($this->_agent,'GT-I9515') !== false  )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S4);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9195') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S4_MINI);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9295') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S4_ACTIVE);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-C101') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S4_ZOOM);
	    	    return true;
	    	}
	    	//S5
	    	if( stripos($this->_agent,'SM-G900') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S5);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-G800') !== false ) 
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S5_MINI);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-G870') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S5_ACTIVE);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-C115') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S5_ZOOM);
	    	    return true;
	    	}
	    	//S6 
	    	if( stripos($this->_agent,'SM-G920') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S6);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-G890') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S6_ACTIVE);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-G9198') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S6_MINI);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-G925') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S6_EDGE);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'SM-G928') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_S6_EDGE_P);
	    	    return true;
	    	}
	    	
	    	
	    	if( stripos($this->_agent,'GT-S5830') !== false ) 
	    	{
			    $this->setBrowser(self::BROWSER_GALAXY_ACE);
			    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I8160') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_ACE_2);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-S7500') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_ACE_PLUS);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-I9250') !== false ||
	    	    stripos($this->_agent,'Galaxy Nexus Build') !== false ) 
	    	{
	    	    $this->setBrowser(self::BROWSER_SAMSUNG_GALAXY_NEXUS);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-N7000') !== false )
	    	{
	    	    $this->setBrowser(self::BROWSER_GALAXY_NOTE);
	    	    return true;
	    	}
	    	if( stripos($this->_agent,'GT-P1000') !== false ||
	    		stripos($this->_agent,'GT-P1010') !== false ||
	    		stripos($this->_agent,'GT-P7100') !== false ||
	    		stripos($this->_agent,'GT-P7300') !== false ||
	    		stripos($this->_agent,'GT-P7510') !== false ||
	    		stripos($this->_agent,'GT-P6200') !== false ||
	    		stripos($this->_agent,'GT-P6210') !== false )
	    	{
			    $this->setBrowser(self::BROWSER_GALAXY_TAB);
			    return true;
	    	}
	    }
	    return false;
    }
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;
    }
113878
public function rules(): array
    {
        $user = $this->user($this->route('guard'));
        $user->updateRulesUniques();

        return $user->getRules();
    }
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 ?? [];
    }
155135
public function rules()
    {
        return array_merge(
            parent::rules(),
            $this->getPasswordHashRules(),
            $this->getPasswordResetTokenRules(),
            $this->getSourceRules(),
            $this->getStatusRules(),
            $this->getAuthKeyRules(),
            $this->getAccessTokenRules()
        );
    }
533739
public function getLimitRules()
    {
        $jsonHelper = new JSONHelper();
        $limits     = $jsonHelper->decodeObject($this->contactClient->getLimits(), 'Limits');

        $this->excludeIrrelevantRules($limits);

        return $this->mergeRules($limits, false);
    }