Creates the AnnotationValidator specified by the value in
{@link org.junit.validator.ValidateWith}. Instances are
cached.

@return An instance of the AnnotationValidator.

@since 4.12
190498
public AnnotationValidator createAnnotationValidator(ValidateWith validateWithAnnotation) {
        AnnotationValidator validator = VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation);
        if (validator != null) {
            return validator;
        }

        Class<? extends AnnotationValidator> clazz = validateWithAnnotation.value();
        try {
            AnnotationValidator annotationValidator = clazz.newInstance();
            VALIDATORS_FOR_ANNOTATION_TYPES.putIfAbsent(validateWithAnnotation, annotationValidator);
            return VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation);
        } catch (Exception e) {
            throw new RuntimeException("Exception received when creating AnnotationValidator class " + clazz.getName(), e);
        }
    }
347329
public FormFieldValidator createValidator(Element constraint, BpmnParse bpmnParse, ExpressionManager expressionManager) {

    String name = constraint.attribute("name");
    String config = constraint.attribute("config");

    if("validator".equals(name)) {

      // custom validators

      if(config == null || config.isEmpty()) {
        bpmnParse.addError("validator configuration needs to provide either a fully " +
        		"qualified classname or an expression resolving to a custom FormFieldValidator implementation.",
        		constraint);

      } else {
        if(StringUtil.isExpression(config)) {
          // expression
          Expression validatorExpression = expressionManager.createExpression(config);
          return new DelegateFormFieldValidator(validatorExpression);
        } else {
          // classname
          return new DelegateFormFieldValidator(config);
        }
      }

    } else {

      // built-in validators

      Class<? extends FormFieldValidator> validator = validators.get(name);
      if(validator != null) {
        FormFieldValidator validatorInstance = createValidatorInstance(validator);
        return validatorInstance;

      } else {
        bpmnParse.addError("Cannot find validator implementation for name '"+name+"'.", constraint);

      }

    }

    return null;


  }
904274
public CsvField<T> add(final CsvFieldValidator<T> validator) {
        Objects.requireNonNull(validator);
        
        validators.add(validator);
        return this;
    }
1010507
public ValidatorType<TldTaglibType<T>> getOrCreateValidator()
   {
      Node node = childNode.getOrCreate("validator");
      ValidatorType<TldTaglibType<T>> validator = new ValidatorTypeImpl<TldTaglibType<T>>(this, "validator", childNode, node);
      return validator;
   }
346098
public static HibernateValidatorConfiguration newConfiguration() {
        return Validation
            .byProvider(HibernateValidator.class)
            .configure()
            .addValueExtractor(GuavaOptionalValueExtractor.DESCRIPTOR.getValueExtractor());
    }
1161306
public static AnnotationInfo.Builder createAnnotation(Class<? extends Annotation> clazz) {
        return AnnotationInfo.builder(valueFormatter).name(clazz);
    }
135623
public static <T extends Annotation> AnnotationValueBuilder<T> builder(Class<T> annotation) {
        return new AnnotationValueBuilder<>(annotation);
    }
884077
public CronDefinition instance() {
        final Set<CronConstraint> validations = new HashSet<>();
        validations.addAll(cronConstraints);
        final List<FieldDefinition> values = new ArrayList<>(fields.values());
        values.sort(FieldDefinition.createFieldDefinitionComparator());
        return new CronDefinition(values, validations, enforceStrictRanges, matchDayOfWeekAndDayOfMonth);
    }
561956
public AnnotationNode annotation(String annotation) {
        this.attr(ANNOTATION, annotation);
        String[] kc = AnnotationParser.extractKeyAndContent(annotation);
        this.attr(ANNOTATION_KEY, kc[0]);
        this.attr(ANNOTATION_CONTENT, kc[1]);
        return this;
    }
328535
public ResultCollectorValidator<D, O> build() {
        final ResultCollectorValidator<D, O> validator = new ResultCollectorValidator<D, O>();

        for (final ResultCollector<?, D> resultCollector : registeredResultCollectors) {
            validator.addResultCollector(resultCollector);
        }
        for (final Rule<Collection<D>, O> rule : registeredRules) {
            validator.addRule(rule);
        }
        for (final ResultHandler<O> resultHandler : registeredResultHandlers) {
            validator.addResultHandler(resultHandler);
        }

        return validator;
    }
813191
public Annotation asAnnotation() {
      if (this instanceof Annotation) {
         return Cast.as(this);
      } else if (document() != null) {
         return document()
                   .annotationBuilder()
                   .type(AnnotationType.ROOT)
                   .bounds(this)
                   .attributes(this)
                   .createDetached();
      }
      return Fragments.detachedAnnotation(AnnotationType.ROOT, start(), end());
   }
134957
@Nonnull
  public static <T> EbInterfaceValidator <T> create (@Nonnull final Class <T> aClass)
  {
    return new EbInterfaceValidator <> (aClass);
  }
485539
protected function getDefaultValidator(): ValidatorInterface
    {
        $loaders = [new StaticMethodLoader()];

        if (class_exists(AnnotationReader::class) && class_exists(ArrayCache::class)) {
            AnnotationRegistry::registerUniqueLoader('class_exists');
            $loaders[] = new AnnotationLoader(new CachedReader(new AnnotationReader(), new ArrayCache()));
        }

        return (new ValidatorBuilder())
            ->setMetadataFactory(
                new LazyLoadingMetadataFactory(
                    new LoaderChain($loaders)
                )
            )
            ->getValidator();
    }
1181093
@Override
	public Validator newValidator(String identifier) {
		if (identifier==null) {
			return null;
		}
		ValidatorFactory template;
		synchronized (map) {
			verifyMapIntegrity();
			template = map.get(identifier);
		}
		if (template!=null) {
			try {
				return template.newValidator(identifier);
			} catch (ValidatorFactoryException e) {
				logger.log(Level.WARNING, "Failed to create validator.", e);
				return null;
			}
		} else {
			return null;
		}
	}
1211092
public void addValidator(Validator validator)
    {
        if (validator == null)
        {
            throw new NullPointerException("validator");
        }
        
        if (_validatorList == null)
        {
            //normally add user 0-3 validators: 
            _validatorList = new _DeltaList<Validator>(new ArrayList<Validator>(3));
        }

        _validatorList.add(validator);
        
        // The argument validator must be inspected for the presence of the ResourceDependency annotation.
        //_handleAnnotations(FacesContext.getCurrentInstance(), validator);
    }
645427
static <A extends Annotation> ImmutableSet<Class<? extends ConstraintValidator<A, ?>>> //
      getValidatorForType(final Class<?> ptype,
          final List<Class<? extends ConstraintValidator<A, ?>>> constraintValidatorClasses) {
    final Class<?> type = Primitives.wrap(ptype);
    final Map<Class<?>, Class<? extends ConstraintValidator<A, ?>>> map = Maps.newHashMap();
    for (final Class<? extends ConstraintValidator<A, ?>> conClass : constraintValidatorClasses) {
      final Class<?> aType = Primitives.wrap(getTypeOfConstraintValidator(conClass));
      if (aType.isAssignableFrom(type)) {
        map.put(aType, conClass);
      }
    }
    // TODO(nchalko) implement per spec
    // Handle Arrays and Generics

    final Set<Class<?>> best = Util.findBestMatches(type, map.keySet());

    final Predicate<Class<?>> inBest = key -> best.contains(key);
    return ImmutableSet.copyOf(Maps.filterKeys(map, inBest).values());
  }
296061
public static ValidatorConfiguration createExperimental() {
        Map<Check, Level> checks = getStandardChecks();

        checks.put(GdlArityCheck.INSTANCE, Level.ERROR);
        checks.put(GdlNotInRuleHeadCheck.INSTANCE, Level.ERROR);
        checks.put(UnrecognizedGdlArgumentCheck.INSTANCE, Level.WARNING);

        // (gdl random)
        checks.put(GdlRandomGoalCheck.INSTANCE, Level.ERROR);

        return new ValidatorConfiguration(checks);
    }