protected function checkDimension($rule, $dimension = 0)
    {

        $dimension = (int) $dimension;

        if ($rule === '*') {
            $message = $this->translator->trans('image-validator::validation.anysize');
            $pass = true;
        } else if (preg_match('/^(\d+)\-(\d+)$/', $rule, $matches)) {
            $size1 = (int) $matches[1];
            $size2 = (int) $matches[2];
            $message = $this->translator->trans('image-validator::validation.between', compact('size1', 'size2'));
            $pass = ($dimension >= $size1) && ($dimension <= $size2);
        } else if (preg_match('/^([<=>]*)(\d+)$/', $rule, $matches)) {

            $size = (int) $matches[2];

            switch ($matches[1]) {
                case '>':
                    $message = $this->translator->trans('image-validator::validation.greaterthan', compact('size'));
                    $pass = $dimension > $size;
                    break;
                case '>=':
                    $message = $this->translator->trans('image-validator::validation.greaterthanorequal',
                        compact('size'));
                    $pass = $dimension >= $size;
                    break;
                case '<':
                    $message = $this->translator->trans('image-validator::validation.lessthan', compact('size'));
                    $pass = $dimension < $size;
                    break;
                case '<=':
                    $message = $this->translator->trans('image-validator::validation.lessthanorequal', compact('size'));
                    $pass = $dimension <= $size;
                    break;
                case '=':
                case '':
                    $message = $this->translator->trans('image-validator::validation.equal', compact('size'));
                    $pass = $dimension == $size;
                    break;
                default:
                    throw new RuntimeException('Unknown image size validation rule: ' . $rule);
            }
        } else {
            throw new RuntimeException('Unknown image size validation rule: ' . $rule);
        }

        return compact('message', 'pass');
    }