Validates the form.

        Args:
            controls: an iterable of ``(key, value)`` tuples
            subcontrol:

        Returns:
            a Colander ``appstruct``

        Raises:
            ValidationFailure: on failure
16295
def validate(self,
                 controls: Iterable[Tuple[str, str]],
                 subcontrol: str = None) -> Any:
        
        try:
            return super().validate(controls, subcontrol)
        except ValidationFailure as e:
            if DEBUG_FORM_VALIDATION:
                log.warning("Validation failure: {!r}; {}",
                            e, self._get_form_errors())
            self._show_hidden_widgets_for_fields_with_errors(self)
            raise
705723
def validate(self):
        
        validation_result = []
        for attr_name, value in [(attr, getattr(self, attr)) for attr in self._attribute_map]:
            attr_desc = self._attribute_map[attr_name]
            if attr_name == "additional_properties" and attr_desc["key"] == '':
                # Do NOT validate additional_properties
                continue
            attr_type = attr_desc['type']

            try:
                debug_name = "{}.{}".format(self.__class__.__name__, attr_name)
                Serializer.validate(value, debug_name, **self._validation.get(attr_name, {}))
            except ValidationError as validation_error:
                validation_result.append(validation_error)

            validation_result += _recursive_validate(attr_name, attr_type, value)
        return validation_result
844767
def validate(self, schema):
        
        try:
            validate(instance=self.to_dict(), schema=schema, cls=Draft4Validator)
        except ValidationError as e:
            raise ValidationError(_validate_err_template.format(VDOM_SCHEMA, e))
1322071
def form_valid(self, form):
        
        form.save()
        return super(SubscriptionView, self).form_valid(form)
1017375
def validate(self, *args, **kwargs): # pylint: disable=arguments-differ
        
        return super(ParameterValidator, self)._validate(*args, **kwargs)
93004
def validate(self, validators, resp_obj):
        
        self.validation_results = []
        if not validators:
            return

        logger.log_debug("start to validate.")

        validate_pass = True
        failures = []

        for validator in validators:
            # validator should be LazyFunction object
            if not isinstance(validator, parser.LazyFunction):
                raise exceptions.ValidationFailure(
                    "validator should be parsed first: {}".format(validators))

            # evaluate validator args with context variable mapping.
            validator_args = validator.get_args()
            check_item, expect_item = validator_args
            check_value = self.__eval_validator_check(
                check_item,
                resp_obj
            )
            expect_value = self.__eval_validator_expect(expect_item)
            validator.update_args([check_value, expect_value])

            comparator = validator.func_name
            validator_dict = {
                "comparator": comparator,
                "check": check_item,
                "check_value": check_value,
                "expect": expect_item,
                "expect_value": expect_value
            }
            validate_msg = "\nvalidate: {} {} {}({})".format(
                check_item,
                comparator,
                expect_value,
                type(expect_value).__name__
            )

            try:
                validator.to_value(self.test_variables_mapping)
                validator_dict["check_result"] = "pass"
                validate_msg += "\t==> pass"
                logger.log_debug(validate_msg)
            except (AssertionError, TypeError):
                validate_pass = False
                validator_dict["check_result"] = "fail"
                validate_msg += "\t==> fail"
                validate_msg += "\n{}({}) {} {}({})".format(
                    check_value,
                    type(check_value).__name__,
                    comparator,
                    expect_value,
                    type(expect_value).__name__
                )
                logger.log_error(validate_msg)
                failures.append(validate_msg)

            self.validation_results.append(validator_dict)

            # restore validator args, in case of running multiple times
            validator.update_args(validator_args)

        if not validate_pass:
            failures_string = "\n".join([failure for failure in failures])
            raise exceptions.ValidationFailure(failures_string)
1032321
public function validate(Control $control): bool
  {
    $value = $control->getSubmittedValue();

    // An empty value is valid.
    if ($value==='' || $value===null || $value===false)
    {
      return true;
    }

    // Objects and arrays are not valid.
    if (!is_scalar($value))
    {
      return false;
    }

    $length = mb_strlen($value, Html::$encoding);

    return (($this->minLength<=$length) && ($length<=$this->maxLength));
  }
163614
def form(self, obj=None, form=None, name=None, template=None, var_name=None, validate_on_submit=True,\
        exit_on_failure=True, csrf_enabled=None):
        
        if not form or isinstance(form, str):
            if not name and isinstance(form, str):
                name = form
            if not name:
                name = request.endpoint.rsplit('.', 1)[1] if '.' in request.endpoint else request.endpoint
            if name not in self.forms:
                raise NoFormError("Cannot find form '%s'" % name)
            form = self.forms[name]
        if inspect.isclass(form):
            if isinstance(obj, dict):
                obj = DictObject(obj)
            if csrf_enabled is None:
                csrf_enabled = self.options["csrf_enabled"]
            form = form(obj=obj, meta={'csrf': csrf_enabled})

        current_context.data.form = form
        yield form

        if validate_on_submit and request.method == "POST":
            self.validate(form, exit_on_failure=exit_on_failure)
349680
def _validate(self):
        
        for key in self:
            if key not in DEFAULTS:
                raise exceptions.ConfigurationException(
                    'Unknown configuration key "{}"! Valid configuration keys are'
                    " {}".format(key, list(DEFAULTS.keys()))
                )

        validate_queues(self["queues"])
        validate_bindings(self["bindings"])
        validate_client_properties(self["client_properties"])
177584
def validate(self, value):
        
        if value in self.empty_values and self.required:
            raise ValidationError(self.error_messages['required'])
898954
private Validator<ValueType> validateLeft() {
        Validator<ValueType> result = null;
        Collection<Validator<ValueType>> subValidators = onGetLeftErrorMessage();

        if (subValidators != null) {
            for (Validator<ValueType> validator : subValidators) {
                notifyOnValidationFailure(validator);

                if (result == null) {
                    result = validator;
                }
            }
        }

        for (Validator<ValueType> validator : validators) {
            if (!validator.validate(getValue())) {
                notifyOnValidationFailure(validator);

                if (result == null) {
                    result = validator;
                }
            }
        }

        return result;
    }
52065
def validate(self, value=None, model=None, context=None):
        
        errors = []
        for validator in self.validators:
            if value is None and not isinstance(validator, Required):
                continue

            error = validator.run(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
            if error:
                errors.append(error)

        return errors
1204357
def handle_valid(self, form=None, *args, **kwargs):
        
        # Take a chance and try save a subclass of a ModelForm.
        if hasattr(form, 'save'):
            form.save()
        # Also try and call handle_valid method of the form itself.
        if hasattr(form, 'handle_valid'):
            form.handle_valid(*args, **kwargs)
412857
def is_valid(self, *states):
        """"""

        # if no state is specified, fallback to the base Form's is_valid
        if not states:
            return super(StateValidatorFormMixin, self).is_valid()

        return all(self.state_validators[state].is_valid(self)
                   for state in states)
679168
def validate(self, data):
        
        for v in self.validators:
            v(self, data)
        return data
362046
def validate(self, value):
        
        for validate in self.validates:
            value = validate(value)
        return value
531903
private WFieldSet getButtonControls(final WValidationErrors errors) {
		// Options Layout
		WFieldSet fieldSet = new WFieldSet("Link configuration");
		WFieldLayout layout = new WFieldLayout();
		layout.setLabelWidth(30);

		layout.addField("Link text", tfLinkLabel);
		layout.addField("Link address", tfUrlField);
		layout.addField("Link AccessKey", tfAccesskey).getLabel().setHint(
				"A single upper case letter or digit.");
		layout.addField("Render as button", cbRenderAsButton);
		layout.addField("Disabled", cbDisabled);
		layout.addField("Open in a new window", cbOpenNew);
		layout.addField("setImage ('/image/attachment.png')", cbSetImage);
		layout.addField("Image Position", ddImagePosition);
		layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 6, 0));

		// Apply Button
		WButton apply = new WButton("Apply");
		apply.setAction(new ValidatingAction(errors, fieldSet) {
			@Override
			public void executeOnValid(final ActionEvent event) {
				applySettings();
			}
		});

		fieldSet.add(layout);
		fieldSet.add(apply);
		return fieldSet;
	}