src/Schema.php
private function processRules(string $key, array $rules, array $insert): array
    {
        $status = true;

        if (!isset($insert[$key])) {
            $status  = false;
            $message = 'Schema key [%s] not present on insert.';
        }

        do {
            $r = array_shift($rules);
            $method = 'checkRule'. ucfirst($r);

            if (!in_array($r, $this->rules)) {
                // There's no rule defined and allowed.
                continue;
            }

            if (!$this->{$method}($insert[$key])) {
                // When given key is not valid we need to stop process
                // and set message related to validation error.
                $status  = false;
                $message = $this->messages()[$r];
                break;
            }

        } while (count($rules));

        return compact('status', 'message');
    }
private function processRules(string $key, array $rules, array $insert): array
    {
        $status = true;

        if (!isset($insert[$key])) {
            $status  = false;
            $message = 'Schema key [%s] not present on insert.';
        }

        do {
            $r = array_shift($rules);
            $method = 'checkRule'. ucfirst($r);

            if (!in_array($r, $this->rules)) {
                // There's no rule defined and allowed.
                continue;
            }

            if (!$this->{$method}($insert[$key])) {
                // When given key is not valid we need to stop process
                // and set message related to validation error.
                $status  = false;
                $message = $this->messages()[$r];
                break;
            }

        } while (count($rules));

        return compact('status', 'message');
    }
private function processRules ( string $ key , array $ rules , array $ insert ) : array { $ status = true ; if ( ! isset ( $ insert [ $ key ] ) ) { $ status = false ; $ message = 'Schema key [%s] not present on insert.' ; } do { $ r = array_shift ( $ rules ) ; $ method = 'checkRule' . ucfirst ( $ r ) ; if ( ! in_array ( $ r , $ this -> rules ) ) { // There's no rule defined and allowed. continue ; } if ( ! $ this -> { $ method } ( $ insert [ $ key ] ) ) { // When given key is not valid we need to stop process // and set message related to validation error. $ status = false ; $ message = $ this -> messages ( ) [ $ r ] ; break ; } } while ( count ( $ rules ) ) ; return compact ( 'status' , 'message' ) ; }
Parse each rules for given key of insert.

@param  string $key
@param  array  $rules
@param  array  $insert
@return array
Parse each rules for given key of insert .