Get the Ext JS Validator

@param string $name
@param array $annotation
@return array
324609
protected function getValidator($name, $annotation) {
        $validate = array();
        switch($name) {
            case 'NotBlank':
            case 'NotNull':
                $validate['type'] = "presence";
                break;
            case 'Email':
                $validate['type'] = "email";
                break;
            case 'Length':
                $validate['type'] = "length";
                $validate['max'] = (int)$annotation->max;
                $validate['min'] = (int)$annotation->min;
                break;
            case 'Regex':
                if ($annotation->match) {
                    $validate['type'] = "format";
                    $validate['matcher']['skipEncode'] = true;
                    $validate['matcher']['value'] = $annotation->pattern;
                }
                break;
            case 'MaxLength':
            case 'MinLength':
                $validate['type'] = "length";
                if ($name == "MaxLength") {
                    $validate['max'] = (int)$annotation->limit;
                } else {
                    $validate['min'] = (int)$annotation->limit;
                }
                break;
            case 'Choice':
                $validate['type'] = "inclusion";
                $validate['list'] = $annotation->choices;
                break;
            default:
                $validate['type'] = strtolower($name);
                $validate += get_object_vars($annotation);
                break;
        }
        return $validate;
    }
937857
public function setValidator($name, $element)
    {
        $name = trim($name);
        if ($name === '') {
            throw new InvalidArgumentException('Empty rule name');
        } elseif (is_array($element) && !empty($element['type'])) {
            $element['parent'] = $this;
            $type = $element['type'];
            unset($element['type']);
            $validator = $this->createValidator($type, $element);
        } elseif (true === ($element instanceof \marvin255\serviform\interfaces\Validator)) {
            $element->setParent($this);
            $validator = $element;
        } else {
            throw new InvalidArgumentException('Wrong child type for rule: ' . $name);
        }
        $this->validators[$name] = $validator;

        return $this;
    }
43176
private function __createAnnotation($name, $string)
    {
        switch ($name) {
            case 'link':
                $annotation = new Annotation\Link($name, $string);
                $annotation->getLinkText();
                break;

            case 'return':
                $annotation = new Annotation\ReturnAnnotation($name, $string);
                $annotation->getReturnType();
                break;

            case 'see':
                $annotation = new Annotation\See($name, $string);
                $annotation->getResource();
                break;

            default:
                $annotation = new Annotation($name, $string);
                break;
        }

        return $annotation;
    }
537437
static function getAnnotation($name, $class, $method = NULL, $nullable = TRUE)
	{
		try {
			NULL === $method or $annotation = self::getMethodAnnotation($method, $name, $class);
			isset($annotation) or $annotation = self::getClassAnnotation($class, $name);
		} catch (ReflectionException $e) {
			$annotation = NULL;
		}

		return !$nullable && NULL === $annotation
			? self::annotationClass($name)
			: $annotation;
	}
824155
protected function _getter($name)
    {
    	// @codingStandardsIgnoreEnd
        $normalized = lcfirst($name);
        $property = "_{$normalized}";
        if (property_exists($this, $property)) {
            /** @var AnnotationsList $annotations */
            $annotations = $this->inspector->getPropertyAnnotations($property);

            if (
                !$annotations->hasAnnotation('@readwrite') &&
                !$annotations->hasAnnotation('@read')
            ) {
                $className = get_class($this);
                throw new Exception\WriteOnlyException(
                    "Trying to read the values of a write only property."
                    ." {$className}::\${$property} has annotation @write."
                );
            }
            return $this->$property;
        }
        return null;
    }
901187
public function getClassAnnotations($className, $annotationClassName = null)
    {
        $className = $this->prepareClassReflectionForUsage($className);

        $annotationClassName = $annotationClassName === null ? null : $this->cleanClassName($annotationClassName);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS])) {
            return [];
        }
        if ($annotationClassName === null) {
            return $this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS];
        }

        $annotations = [];
        foreach ($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS] as $annotation) {
            if ($annotation instanceof $annotationClassName) {
                $annotations[] = $annotation;
            }
        }

        return $annotations;
    }
524143
static function annotationClass($name)
	{
		if (!AnnotationRegistry::loadAnnotationClass($name)) {
			throw new \Doctrine\Common\Annotations\AnnotationException('Annotation ' . $name . ' - not exists');
		}

		return new $name;
	}
644651
private function normalizeAnnotation(Annotation $annotation)
    {
        return [
            'value' => $annotation->getValue(),
            'timestamp' => $annotation->getTimestamp(),
            'endpoint' => null !== $annotation->getHost() ? $this->normalizeEndpoint($annotation->getHost()) : null,
        ];
    }
698644
public function getJsonArray($annotation, $default = []) {
        $str = $this->getString($annotation);
        if (is_array($str)) {
            $rst = [];
            foreach ($str as $s) {
                $ss = preg_split('/\s+/', $s, 2);
                if (count($ss) == 2) {
                    list($k, $v) = $ss;
                } else {
                    $k = $ss[0];
                    $v = 1;
                }
                $rst[ $k ] = $v;
            }

            return $rst;
        }
        if ($str) {
            $str = trim($str);
            if (preg_match('#^[\[\{](.*)[\}\]]$#', $str)) {
                $rst = json_decode($str, true);
                if ($rst) {
                    return $rst;
                } else {
                    trigger_error($str . ' ' . json_last_error_msg(), E_USER_WARNING);
                }
            } else {
                @parse_str($str, $rst);
                if ($rst) {
                    return $rst;
                }
                trigger_error($str . ' Syntax error', E_USER_WARNING);
            }
        }

        return $default;
    }
1130515
public function parseReflectedController($name, ClassReflection $reflection, ArrayObject $config)
    {
        $annotations = $reflection->getAnnotations($this->annotationManager);

        if ($annotations instanceof AnnotationCollection) {
            $this->processor->processController($name, $annotations);
        }

        foreach ($reflection->getMethods() as $method) {
            $annotations = $method->getAnnotations($this->annotationManager);

            if (!$annotations instanceof AnnotationCollection) {
                continue;
            }

            $this->processor->processMethod($method->getName(), $annotations, $config);
        }

        return $config;
    }
207463
public function buildValidator(Event $event, Validator $validator, $name)
    {
        foreach ((array)$this->getConfig('displayField') as $field) {
            if (strpos($field, '.') === false) {
                $validator->requirePresence($field, 'create')
                    ->notEmpty($field);
            }
        }
    }
748307
public function getValidator($name = '')
    {
        if ($this->dirty || !isset($this->validator[$name]) || $this->validator[$name] == null) {
            $this->validator[$name] = $this->buildValidator($this->validators, $name);
            $this->dirty = false;
        }

        return $this->validator[$name];
    }
232204
public static function createFromString($annotation) {
		preg_match('/^\@mixin (.+)\s*(.+)?$/', $annotation, $matches);
		if ($matches) {
			return static::create('@mixin', $matches[1]);
		}

		preg_match('/^(\@property|\@method|\@var|\@param) ([^ ]+) (.+)$/', $annotation, $matches);
		if (!$matches) {
			return null;
		}
		return static::create($matches[1], $matches[2], $matches[3]);
	}
102862
protected function getValidationConfiguration(Field $field, $validationName, Validation $validatorConfiguration)
    {
        $acceptsEmptyValues = ValidatorService::get()->validatorAcceptsEmptyValues($validatorConfiguration->getClassName());

        /** @var FormzLocalizationJavaScriptAssetHandler $formzLocalizationJavaScriptAssetHandler */
        $formzLocalizationJavaScriptAssetHandler = $this->assetHandlerFactory->getAssetHandler(FormzLocalizationJavaScriptAssetHandler::class);

        $messages = $formzLocalizationJavaScriptAssetHandler->getTranslationKeysForFieldValidation($field, $validationName);

        return ArrayService::get()->arrayToJavaScriptJson([
            'options'            => $validatorConfiguration->getOptions(),
            'messages'           => $messages,
            'settings'           => $validatorConfiguration->toArray(),
            'acceptsEmptyValues' => $acceptsEmptyValues
        ]);
    }
596700
public function getAnnotationParam($name, $param, $methodName = NULL, $default = NULL)
	{
		return Annotations::getAnnotationParam($name, $param, $this, $methodName, $default);
	}
1242751
protected static function getChecker($name)
    {
        return function (Update $update) use ($name) {
            $message = $update->getMessage();
            if (is_null($message) || !strlen($message->getText())) {
                return false;
            }

            preg_match(self::REGEXP, $message->getText(), $matches);

            return !empty($matches) && $matches[1] == $name;
        };
    }
422702
protected function getValidatorDefine(string $name)
    {
        if (isset($this->builtinValidators[$name])) {
            return $this->builtinValidators[$name];
        }

        if (isset($this->customValidators[$name])) {
            return $this->customValidators[$name];
        }

        return false;
    }