Factory that obtains a Validator instance based on the schema language.

@see Languages
512813
public static Validator forLanguage(String language) {
        if (!Languages.XML_DTD_NS_URI.equals(language)) {
            return new JAXPValidator(language);
        }
        return new ParsingValidator(Languages.XML_DTD_NS_URI);
    }
675659
public function validator()
    {
        return Validator::make(
            $this->params, $this->rules(),
            $this->messages(), $this->attributes()
        );
    }
944612
public function validateMapping()
    {
        try {
            $validator = new SchemaValidator($this->entityManager);
            return $validator->validateMapping();
        } catch (\Exception $exception) {
            return [[$exception->getMessage()]];
        }
    }
280768
public static Validator validTrustManagerFactory() {
    return (s, o) -> {
      if (!(o instanceof String)) {
        throw new ConfigException(s, o, "Must be a string.");
      }

      String keyStoreType = o.toString();
      try {
        TrustManagerFactory.getInstance(keyStoreType);
      } catch (NoSuchAlgorithmException e) {
        ConfigException exception = new ConfigException(s, o, "Invalid Algorithm");
        exception.initCause(e);
        throw exception;
      }
    };
  }
757435
public static Validator validKeyManagerFactory() {
    return (s, o) -> {
      if (!(o instanceof String)) {
        throw new ConfigException(s, o, "Must be a string.");
      }

      String keyStoreType = o.toString();
      try {
        KeyManagerFactory.getInstance(keyStoreType);
      } catch (NoSuchAlgorithmException e) {
        ConfigException exception = new ConfigException(s, o, "Invalid Algorithm");
        exception.initCause(e);
        throw exception;
      }
    };
  }
567056
def make_request_validator(request):
    """"""
    verb = request.values.get('verb', '', type=str)
    resumption_token = request.values.get('resumptionToken', None)

    schema = Verbs if resumption_token is None else ResumptionVerbs
    return getattr(schema, verb, OAISchema)(partial=False)
989824
def _verify_validator(self, validator, path):
        """"""

        # Validator should be a function
        if not callable(validator):
            raise SchemaFormatException("Invalid validations for {}", path)

        # Validator should accept a single argument
        (args, varargs, keywords, defaults) = getargspec(validator)
        if len(args) != 1:
            raise SchemaFormatException("Invalid validations for {}", path)
114193
public function validateInstance() {
		$instanceName = MoufManager::getMoufManager()->findInstanceName($this);
			
		if (!file_exists(ROOT_PATH.$this->i18nMessagePath."message.php")) {
			return new MoufValidatorResult(MoufValidatorResult::ERROR, "<b>Fine: </b>Unable to find default translation file for instance: <code>".ROOT_PATH.$this->i18nMessagePath."message.php</code>.<br/>"
															."You should create the following files:<br/>"
															.$this->i18nMessagePath."message.php <a href='".ROOT_URL."vendor/mouf/mouf/editLabels/createMessageFile?name=".$instanceName."&selfedit=false&language=default'>(create this file)</a>");
		}
		else {
			$this->loadAllMessages();
			
			// The array of messages by message, then by language:
			// array(message_key => array(language => message))
			$keys = $this->getAllKeys();
			foreach ($keys as $key) {
				$msgs = $this->getMessageForAllLanguages($key);
				if (!isset($msgs['default'])) {
					$missingDefaultKeys[$instanceName][] = $key;
				}
			}
			if (empty($missingDefaultKeys)) {
				return new MoufValidatorResult(MoufValidatorResult::SUCCESS, "<b>Fine: </b>Default translation file found in instance <code>$instanceName</code>.<br />
																				Default translation is available for all messages.");
			} else {
				$html = "";
				foreach ($missingDefaultKeys as $instanceName=>$missingKeys) {
					$html .= "<b>Fine: </b>A default translation in '".$instanceName."' is missing for these messages: ";
					foreach ($missingKeys as $missingDefaultKey) {
						$html .= "<a href='".ROOT_URL."vendor/mouf/mouf/editLabels/editLabel?key=".urlencode($missingDefaultKey)."&language=default&backto=".urlencode(ROOT_URL)."mouf/&msginstancename=".urlencode($instanceName)."'>".$missingDefaultKey."</a> ";
					}
					$html .= "<hr/>";
				}
				return new MoufValidatorResult(MoufValidatorResult::WARN, $html);
			}
			
		}
	}
528094
def factory(obj, field, source_text, lang, context=""):
		

		# Model name
		obj_classname = obj.__class__.__name__

		# Module name
		obj_module = obj.__module__
		
		# Computation of MD5 of the source text
		source_md5 = checksum(source_text)

		# Translated text
		translation = ""

		# Translation text attribute name
		field_lang = trans_attr(field,lang)

		# If in source object there is a translation and is not empty, we asume it was assigned and it's correct
		if hasattr(obj,field_lang) and getattr(obj,field_lang)!="":
			translation = getattr(obj,field_lang)

		# Is the translation fuzzy?
		is_fuzzy = True
		is_fuzzy_lang = trans_is_fuzzy_attr(field,lang)
		if hasattr(obj,is_fuzzy_lang):
			is_fuzzy = getattr(obj,is_fuzzy_lang)

		# Construction of the translation
		trans = FieldTranslation(module=obj_module, model=obj_classname, object_id=obj.id,
		                         field=field, lang=lang, source_text=source_text, source_md5=source_md5,
		                         translation=translation, is_fuzzy=is_fuzzy, context=context)
		return trans
515524
public static function getValidator(string $locale = 'en_US'): Factory {
    $translator       = new Translator($locale, new MessageSelector());
    $validatorFactory = new Factory($translator);

    return $validatorFactory;
  }
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;
   }
413191
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(!$exists) {
            return true;
        }
        
        if(!\is_callable($value)) {
            return 'formvalidator_make_callable';
        }
        
        if(empty($options)) {
            throw new \LogicException('Invalid options value given for callback rule');
        }
        
        /** @var \ReflectionMethod|\ReflectionFunction  $prototype */
        
        if(\is_array($value)) {
            $prototype = new \ReflectionMethod($value[0], $value[1]);
        } else {
            $prototype = new \ReflectionFunction($value);
        }
        
        $options = \explode('=', $options, 2);
        
        if(!empty($options[0])) {
            $params = \explode(',', $options[0]);
            
            /** @var \ReflectionParameter  $param */
            foreach($prototype->getParameters() as $pos => $param) {
                $type = $param->getType();
                
                if(!isset($params[$pos])) {
                    return array('formvalidator_make_callback_param_superfluos', array('{0}' => $pos));
                } elseif($params[$pos] === '') {
                    continue; // "mixed" type - wildcard
                } elseif(($type === null && $params[$pos] !== '') || \trim($params[$pos], '?') !== $type->getName()) {
                    return array('formvalidator_make_callback_param', array('{0}' => $pos, '{1}' => \trim($params[$pos], '?')));
                } elseif($params[$pos][0] === '?' && !$type->allowsNull()) {
                    return array('formvalidator_make_callback_param_nullable', array('{0}' => $pos));
                } elseif(\substr($params[$pos], -1) === '?' && !$param->isOptional()) {
                    return array('formvalidator_make_callback_param_optional', array('{0}' => $pos));
                }
            }
        }
        
        if(!empty($options[1])) {
            $return = $prototype->getReturnType();
            
            if($return === null) {
                return array('formvalidator_make_callback_return', array('{0}' => $options[1]));
            } elseif(($return->allowsNull() ? '?' : '').$return->getName() !== $options[1]) {
                return array('formvalidator_make_callback_return_type', array('{0}' => $options[1], '{1}' => $return->getName()));
            }
        }
        
        return true;
    }
323017
public FacesConfigValidatorType<WebFacesConfigDescriptor> getOrCreateValidator()
   {
      List<Node> nodeList = model.get("validator");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigValidatorTypeImpl<WebFacesConfigDescriptor>(this, "validator", model, nodeList.get(0));
      }
      return createValidator();
   }
1222362
public function getValidator(array $rules = []): Validator
    {
        $parser = new RulesParser($this->factories);

        return new Validator($rules, $parser, $this->translator);
    }
301306
public static function create(string $locale = 'en'): ValidatorFactory
    {
        $translator = new Translator;

        $factory = new ValidatorFactory($translator);
        $factory = $factory->withBuiltInFactories();
        $factory = $factory->withBuiltInTemplates($locale);

        return $factory;
    }
991363
def get_schema_validator(self, schema_name):
        

        if schema_name not in self.schemas:
            schema_file = self.get_schema_file(schema_name)
            with open(schema_file) as f:
                try:
                    jsn_schema = json.load(f)
                except ValueError as ex:
                    log.error("Could not load %s", schema_file)
                    raise ex

            schemas_folder = self.get_schemas_folder()
            root_schema_path = self.get_schema_path(schemas_folder)
            resolver = jsonschema.RefResolver(root_schema_path, None)
            # cache the schema for future use
            self.schemas[schema_name] = (jsn_schema, resolver)
        else:
            jsn_schema, resolver = self.schemas[schema_name]

        validator = jsonschema.Draft4Validator(schema=jsn_schema, resolver=resolver)
        # validator.check_schema(jsn_schema) # check schema is valid

        return validator
1032604
private Validator createNewErrorValidator() {
        final Validator validator = schema.newValidator();
        validator.setErrorHandler(new Handler());
        return validator;
    }