Return formatter validation error.
337244
def validation_error(exception):
    """"""
    messages = getattr(exception, 'messages', None)
    if messages is None:
        messages = getattr(exception, 'data', {'messages': None})['messages']

    def extract_errors():
        """Extract errors from exception."""
        if isinstance(messages, dict):
            for field, message in messages.items():
                if field == 'verb':
                    yield 'badVerb', '\n'.join(message)
                else:
                    yield 'badArgument', '\n'.join(message)
        else:
            for field in exception.field_names:
                if field == 'verb':
                    yield 'badVerb', '\n'.join(messages)
                else:
                    yield 'badArgument', '\n'.join(messages)

            if not exception.field_names:
                yield 'badArgument', '\n'.join(messages)

    return (etree.tostring(xml.error(extract_errors())),
            422,
            {'Content-Type': 'text/xml'})
655644
function format(err, options) {
    const error = { message: 'Internal Server Error' };

    options = options || {};

    if (options.exposeErrors || (err.httpStatusCode && err.httpStatusCode < 500)) {
        error.message = err.message;
        if (err.code) error.code = err.code;
        if (err.validation) error.validation = err.validation;
    }

    if (options.exposeErrors) {
        if (err.stack) error.stack = err.stack.split(/\r?\n/);

        if (err.info) {
            Object.keys(err.info).forEach(key => {
                if (!has(error, key) && has(err.info, key)) error[key] = err.info[key];
            });
        }
    }

    return error;
}
1341281
def default_formatter(handler, item, value):
    """"""
    if hasattr(value, '__unicode__'):
        value = value.__unicode__()

    return escape(str(value))
61997
def validate_format(self, allowed_formats):
        
        if self.format in allowed_formats:
            return

        ui.error("Export type '{0}' does not accept '{1}' format, only: "
                 "{2}".format(self.type, self.format, allowed_formats))
        sys.exit(1)
1162038
def validate(self):
        
        validator = Draft7Validator(self.SCHEMA)

        errors = set()  # make errors a set to avoid duplicates

        for error in validator.iter_errors(self.serialize()):
            errors.add('.'.join(
                list(map(str, error.path)) + [error.message]
            ))

        if errors:
            raise JSONValidationException(type(self).__name__, errors)
1060215
def error_lineno(self):
        """"""
        if isinstance(self.docstring, Docstring):
            return self.docstring.start
        return self.start
477784
def validate(self, input_parameters, context):
        """"""
        errors = {}

        for key, type_handler in self.input_transformations.items():
            if self.raise_on_invalid:
                if key in input_parameters:
                    input_parameters[key] = self.initialize_handler(
                        type_handler,
                        input_parameters[key],
                        context=context
                    )
            else:
                try:
                    if key in input_parameters:
                        input_parameters[key] = self.initialize_handler(
                            type_handler,
                            input_parameters[key],
                            context=context
                        )
                except InvalidTypeData as error:
                    errors[key] = error.reasons or str(error.message)
                except Exception as error:
                    if hasattr(error, 'args') and error.args:
                        errors[key] = error.args[0]
                    else:
                        errors[key] = str(error)
        for require in self.required:
            if not require in input_parameters:
                errors[require] = "Required parameter '{}' not supplied".format(require)
        if not errors and getattr(self, 'validate_function', False):
            errors = self.validate_function(input_parameters)
        return errors
1085995
def format_errors(errors):
        

        def _get_message(node):
            """
            Get the message to display in the error output.
            """
            messages = set()

            try:
                messages.update([node['message']])
            except KeyError:
                pass

            for check_group in ['any', 'all', 'none']:
                try:
                    for check in node[check_group]:
                        messages.update([check.get('message')])
                except KeyError:
                    pass

            messages = messages.difference([''])
            return '; '.join(messages)

        lines = []
        for error_type in errors:
            lines.append(u"Severity: {}".format(error_type.get("impact")))
            lines.append(u"Rule ID: {}".format(error_type.get("id")))
            lines.append(u"Help URL: {}\n".format(error_type.get('helpUrl')))

            for node in error_type['nodes']:
                msg = u"Message: {}".format(_get_message(node))
                html = u"Html: {}".format(node.get('html').encode('utf-8'))
                target = u"Target: {}".format(node.get('target'))
                fill_opts = {
                    'width': 100,
                    'initial_indent': '\t',
                    'subsequent_indent': '\t\t',
                }
                lines.append(fill(msg, **fill_opts))
                lines.append(fill(html, **fill_opts))
                lines.append(fill(target, **fill_opts))
                lines.append('\n')

        return '\n'.join(lines)
185077
def _validate_xtext(xtext):
    """"""

    non_printables = _non_printable_finder(xtext)
    if non_printables:
        xtext.defects.append(errors.NonPrintableDefect(non_printables))
    if utils._has_surrogates(xtext):
        xtext.defects.append(errors.UndecodableBytesDefect(
            "Non-ASCII characters found in header token"))
593431
def validate(self, data):
        """"""
        validated = self._validated(data)
        errors = []
        for validator in self.additional_validators:
            if not validator(validated):
                errors.append(
                    "%s invalidated by '%s'" % (
                        validated, _get_repr(validator)))
        if errors:
            raise NotValid(*errors)

        if self.default is UNSPECIFIED:
            return validated

        if self.null_values is not UNSPECIFIED\
                and validated in self.null_values:
            return self.default

        if validated is None:
            return self.default

        return validated
1159237
def format_errors(self, errors, many):
        """"""
        if not errors:
            return {}
        if isinstance(errors, (list, tuple)):
            return {'errors': errors}

        formatted_errors = []
        if many:
            for index, errors in iteritems(errors):
                for field_name, field_errors in iteritems(errors):
                    formatted_errors.extend([
                        self.format_error(field_name, message, index=index)
                        for message in field_errors
                    ])
        else:
            for field_name, field_errors in iteritems(errors):
                formatted_errors.extend([
                    self.format_error(field_name, message)
                    for message in field_errors
                ])
        return {'errors': formatted_errors}
480761
function formatError(error) {
        function localize(key) {
            if (Strings[key]) {
                return Strings[key];
            }
            console.log("Unknown installation error", key);
            return Strings.UNKNOWN_ERROR;
        }

        if (Array.isArray(error)) {
            error[0] = localize(error[0]);
            return StringUtils.format.apply(window, error);
        } else {
            return localize(error);
        }
    }
1353075
def _validation_error(prop, prop_type, prop_value, expected):
    

    if prop_type is None:
        attrib = 'value'
        assigned = prop_value
    else:
        attrib = 'type'
        assigned = prop_type

    raise ValidationError(
        'Invalid property {attrib} for {prop}:\n\t{attrib}: {assigned}\n\texpected: {expected}',
        attrib=attrib, prop=prop, assigned=assigned, expected=expected,
        invalid={prop: prop_value} if attrib == 'value' else {}
    )
1274884
function formatErrors(errors, formatters, errorType) {
  const format = (formatter) => formatter(errors, errorType) || [];
  const flatten = (accum, curr) => accum.concat(curr);

  return formatters.map(format).reduce(flatten, [])
}
1047113
def validate(self, instance, value):
        """"""
        if not isinstance(value, uuid.UUID):
            self.error(instance, value)
        return value
784479
function(error) {
  return util.format('  %s: %s',
    chalk.magenta(error.plugin.name),
    error.message);
}
524622
def validate(self):
        
        from pyrocore.torrent import formatting

        super(PatternFilter, self).validate()
        self._value = self._value.lower()
        self._template = None
        self._is_regex = self._value.startswith('/') and self._value.endswith('/')
        if self._is_regex:
            self._matcher = re.compile(self._value[1:-1]).search
        elif self._value.startswith('{{') or self._value.endswith('}}'):
            def _template_globber(val, item):
                """Helper."""
                pattern = formatting.format_item(self._template, item).replace('[', '[[]')
                ##print('!!!', val, '~~~', pattern, '???')
                return fnmatch.fnmatchcase(val, pattern.lower())

            self._template = formatting.preparse(self._value)
            self._matcher = _template_globber
        else:
            self._matcher = lambda val, _: fnmatch.fnmatchcase(val, self._value)