Creates a validated configuration object.

@throws IllegalArgumentException if there is an error in the config object.
974039
public static ValidatedConformanceConfig create(ConformanceConfig config) {
    ImmutableList.Builder<RuleWithWhitelists> rulesBuilder = new ImmutableList.Builder<>();
    for (Requirement requirement : config.getRequirementList()) {
      Preconditions.checkArgument(
          !requirement.getErrorMessage().isEmpty(), "requirement missing error message");
      Preconditions.checkArgument(
          requirement.getRequirementTypeCase() != RequirementTypeCase.REQUIREMENTTYPE_NOT_SET,
          "requirement missing type");
      Rule<? extends Node> rule = forRequirement(requirement);
      ImmutableList<String> whitelists = ImmutableList.copyOf(requirement.getWhitelistList());
      ImmutableList<String> onlyApplyToPaths =
          ImmutableList.copyOf(requirement.getOnlyApplyToList());
      rulesBuilder.add(RuleWithWhitelists.create(rule, whitelists, onlyApplyToPaths));
    }
    return new ValidatedConformanceConfig(rulesBuilder.build());
  }
1321023
public static HibernateValidatorConfiguration newConfiguration() {
        return BaseValidator.newConfiguration()
                .constraintValidatorFactory(new MutableValidatorFactory())
                .parameterNameProvider(new JerseyParameterNameProvider())
                .addValueExtractor(NonEmptyStringParamValueExtractor.DESCRIPTOR.getValueExtractor())
                .addValueExtractor(ParamValueExtractor.DESCRIPTOR.getValueExtractor());
    }
180730
protected function assertConfigIsValid(): void
    {
        foreach ($this->configProperties as $property) {
            if (empty(self::$config[$this->configSectionName][$property])) {
                throw new InvalidConfigException(
                    sprintf(
                        "Config section does not exist or is not filled properly: %s (\"%s\" is missing)",
                        $this->configSectionName,
                        $property
                    )
                );
            }
        }

        $this->assertApiClassImplementsInterface($this->apiInterface);
    }
1095473
protected function addLoadValidatorMetadataMethod()
    {
        $params = $this->getParameters();
        $constraints = [];

        foreach ($params as $key => $properties) {
            if (!isset($properties['column'])) {
                throw new InvalidArgumentException('Please, define the column to validate.');
            }

            if (!isset($properties['validator'])) {
                throw new InvalidArgumentException('Please, define the validator constraint.');
            }

            if (!class_exists("Symfony\\Component\\Validator\\Constraints\\".$properties['validator'], true)) {
                if (!class_exists("Propel\\Runtime\\Validator\\Constraints\\".$properties['validator'], true)) {
                    throw new ConstraintNotFoundException('The constraint class '.$properties['validator'].' does not exist.');
                } else {
                    $classConstraint = "Propel\\Runtime\\Validator\\Constraints\\".$properties['validator'];
                }
            } else {
                $classConstraint = "Symfony\\Component\\Validator\\Constraints\\".$properties['validator'];
            }

            if (isset($properties['options'])) {
                if (!is_array($properties['options'])) {
                    throw new InvalidArgumentException('The options value, in <parameter> tag must be an array');
                }

                $opt = var_export($properties['options'], true);
                $opt = str_replace("\n", '', $opt);
                $opt = str_replace('  ', '', $opt);
                $properties['options'] = $opt;
            }

            $constraints[] = $properties;
            $this->builder->declareClass($classConstraint);
        }

        return $this->renderTemplate('objectLoadValidatorMetadata', ['constraints' => $constraints]);
    }
823274
def _validate_config(self, config):
        
        required_keys = [
            self.KEY_IDP_CONFIG,
            self.KEY_ENDPOINTS,
        ]

        if not config:
            raise ValueError("No configuration given")

        for key in required_keys:
            try:
                _val = config[key]
            except KeyError as e:
                raise ValueError("Missing configuration key: %s" % key) from e
612926
def _validate_helper(args, config_d, workspace_d, entity_d=None):
    
        # 4 ways to have invalid config:
    invalid_inputs = sorted(config_d["invalidInputs"])
    invalid_outputs = sorted(config_d["invalidOutputs"])

    # Also insert values for invalid i/o
    invalid_inputs = [(i, config_d['methodConfiguration']['inputs'][i]) for i in invalid_inputs]
    invalid_outputs = [(i, config_d['methodConfiguration']['outputs'][i]) for i in invalid_outputs]

    missing_attrs = []
    missing_wksp_attrs = []

    # If an entity was provided, also check to see if that entity has the necessary inputs
    if entity_d:
        entity_type = config_d['methodConfiguration']['rootEntityType']

        # If the attribute is listed here, it has an entry
        entity_attrs = set(entity_d['attributes'])

        # Optimization, only get the workspace attrs if the method config has any
        workspace_attrs = workspace_d['workspace']['attributes']

        # So now iterate over the inputs
        for inp, val in iteritems(config_d['methodConfiguration']['inputs']):
            # Must be an attribute on the entity
            if val.startswith("this."):
                # Normally, the value is of the form 'this.attribute',
                # but for operations on sets, e.g. one can also do
                # 'this.samples.attr'. But even in this case, there must be a
                # 'samples' attribute on the sample set, so checking for the middle
                # value works as expected. Other pathological cases would've been
                # caught above by the validation endpoint
                expected_attr = val.split('.')[1]
                # 'name' is special, it really means '_id', which everything has
                if expected_attr == "name":
                    continue
                if expected_attr not in entity_attrs:
                    missing_attrs.append((inp, val))

            if val.startswith("workspace."):
                # Anything not matching this format will be caught above
                expected_attr = val.split('.')[1]
                if expected_attr not in workspace_attrs:
                    missing_wksp_attrs.append((inp, val))
            # Anything else is a literal

    return invalid_inputs, invalid_outputs, missing_attrs, missing_wksp_attrs
762064
def _validate(self):
        
        errors = []
        for k in self._defaults.keys():
            try:
                validator = self._defaults[k]['validator']
                if validator is not None:
                    self[k] = validator(self[k])
            except ValueError as e:
                errors.append('\t{}: {}'.format(k, six.text_type(e)))

        if errors:
            raise ValueError(
                'Invalid configuration values were set: \n{}'.format('\n'.join(errors)))
1153587
private static void validateSetting(ConfigurationSetting setting) {
        Objects.requireNonNull(setting);

        if (setting.key() == null) {
            throw new IllegalArgumentException("Parameter 'key' is required and cannot be null.");
        }
    }
1075849
function _validateConfig(configObject, mittoObject) {
  var packageObject = _findFile('package.json');
  if (!mittoObject) {
    return configObject;
  }

  if (!configObject && mittoObject.required && Object.keys(mittoObject.required).length) {
    throw new Error(mittoObject.name + " configuration file not found, and is required by " + packageObject.name);
  } else if (!configObject && mittoObject.hasDefault) {
    return _addOnDefaults({}, mittoObject);
  } else if (!configObject) {
    return configObject;
  }

  for (var key in mittoObject.required) {
    if (!configObject.hasOwnProperty(key)) {
      throw new Error("Required property " + key + " not found in " + mittoObject.name);
    } else if (_typeof(configObject[key]) !== mittoObject.required[key].type) {
      throw new Error("Required property " + key + " expected to be of type " + mittoObject.required[key].type);
    }
  }

  for (var key in mittoObject.optional) {
    if (configObject[key] && _typeof(configObject[key]) !== mittoObject.optional[key].type) {
      throw new Error("Optional property " + key + " is type " + _typeof(configObject[key]) + " and expected to be of type " + mittoObject.optional[key].type);
    }
  }

  if (mittoObject.hasDefault) {
    return _addOnDefaults(configObject, mittoObject);
  }

  return configObject;
}
1365500
public void validateConfiguration(String configuration) {

        try {
            JSONObject json = new JSONObject(configuration);
            String className = json.optString(CmsDataViewConstants.CONFIG_VIEW_CLASS);

            Class<?> cls = Class.forName(className, false, getClass().getClassLoader());
            if (!I_CmsDataView.class.isAssignableFrom(cls)) {
                throw new IllegalArgumentException(
                    "Class " + cls.getName() + " does not implement " + I_CmsDataView.class.getName());
            }
        } catch (Exception e) {
            throw new CmsWidgetConfigurationException(e);
        }

    }
227561
protected function validateConfig()
    {
        $defaults = [
            'tpl_folder',
            'cache_folder',
            'tpl_file_format',
            //'compress',
            //'event_emitter',
        ];

        foreach ($defaults as $key) {
            if (! isset($this->config[$key])) {
                throw new InvalidConfigException(sprintf("Missing a configuration key (%s)", $key));
            }
        }
    }
130846
@Override
    public Configuration<?> configure() throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "configure");
        }

        Configuration<?> configuration = null;
        Class<? extends ValidationProvider<?>> clazz = this.getDefaultProviderClass();
        if (clazz == null) {
            // get configuration object from default provider.
            configuration = Validation.byDefaultProvider().configure();

        } else {
            @SuppressWarnings("unchecked")
            ProviderSpecificBootstrap<?> providerBootstrap = Validation.byProvider((Class) clazz);
            configuration = providerBootstrap.configure();
        }

        setMessageInterpolator(configuration);
        setTraversableResolver(configuration);
        setConstraintValidatorFactory(configuration);
        setConstraintMappings(configuration);
        setProperties(configuration);

        // Indicate to the provider configuration that xml should be ignored. We do this
        // because we need to find the correct xml's for each module, as the provider doesn't
        // guarantee this in an EE environment.
        configuration.ignoreXmlConfiguration();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "configure", configuration);
        }

        return configuration;
    }
336622
BaseConfiguration addDefaultConfiguration(InputStream defaultConfig) throws ConfigValidationException, ConfigUpdateException {
        return defaultConfiguration.add(defaultConfig, serverXMLConfig, variableRegistry);
    }
980238
static void validateConfigurations(Configuration conf) throws ValidationException {
        if (null == conf.getHandlers()) {
            Log.error(
                    "Handler should not be null, One or more handler implementation shuld be configured in the configuration",
                    ErrorGuide.getGuide(ErrorGuide.EMPTY_HANDLERS));
            throw new ValidationException("Configuration error", ValidationException.VALIDATION_LEVEL_INVALID);
        }
        if (null == conf.getLayout()) {
            Log.error("Layout should not be null, A layout implementation shuld be configured in the configuration",
                    ErrorGuide.getGuide(ErrorGuide.EMPTY_LAYOUT));
            throw new ValidationException("Configuration error", ValidationException.VALIDATION_LEVEL_INVALID);
        }

    }
811534
public RestRouterConfiguration build() {
        if (this.enabled) {
            try {
                validate();
            } catch (Exception e) {
                throw logger.configurationValidationError(e);
            }
            return new RestRouterConfiguration(ip, port);
        }
        return null;
    }
1267638
@Validate
    public Validator initialize() {
        // configure and build an instance of ValidatorFactory
        ProviderSpecificBootstrap<HibernateValidatorConfiguration> validationBootStrap = javax.validation.Validation
                .byProvider(HibernateValidator.class);

        // bootstrap to properly resolve in an OSGi environment
        validationBootStrap.providerResolver(new HibernateValidationProviderResolver());

        HibernateValidatorConfiguration configure = validationBootStrap.configure().messageInterpolator(interpolator);
        interpolator.setDefaultInterpolator(configure.getDefaultMessageInterpolator());

        // now that we've done configuring the ValidatorFactory, let's build it
        ValidatorFactory validatorFactory = configure.buildValidatorFactory();

        // retrieve a unique validator.
        Validator validator = validatorFactory.getValidator();

        // Register the validator.
        if (context != null) {
            registration = context.registerService(Validator.class, new WrappedValidator(validator), null);
            factoryRegistration = context.registerService(ValidatorFactory.class, validatorFactory, null);
        }

        return validator;
    }
1125257
final public function create() {
        global $DB, $USER;

        if ($this->raw_get('id')) {
            // The validation methods rely on the ID to know if we're updating or not, the ID should be
            // falsy whenever we are creating an object.
            throw new coding_exception('Cannot create an object that has an ID defined.');
        }

        if (!$this->is_valid()) {
            throw new invalid_persistent_exception($this->get_errors());
        }

        // Before create hook.
        $this->before_create();

        // We can safely set those values bypassing the validation because we know what we're doing.
        $now = time();
        $this->raw_set('timecreated', $now);
        $this->raw_set('timemodified', $now);
        $this->raw_set('usermodified', $USER->id);

        $record = $this->to_record();
        unset($record->id);

        $id = $DB->insert_record(static::TABLE, $record);
        $this->raw_set('id', $id);

        // We ensure that this is flagged as validated.
        $this->validated = true;

        // After create hook.
        $this->after_create();

        return $this;
    }