How to use the pykwalify.errors.SchemaError.SchemaErrorEntry function in pykwalify

To help you get started, we’ve selected a few pykwalify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Grokzen / pykwalify / pykwalify / core.py View on Github external
msg=u"Type '{prefix}' has size of '{value}', greater than max limit '{max_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_=max_))

        if min_ is not None and min_ > value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_=min_))

        if max_ex is not None and max_ex <= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than or equals to max limit(exclusive) '{max_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_ex=max_ex))

        if min_ex is not None and min_ex >= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than or equals to min limit(exclusive) '{min_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_ex=min_ex))
github Grokzen / pykwalify / pykwalify / core.py View on Github external
msg=u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_=min_))

        if max_ex is not None and max_ex <= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than or equals to max limit(exclusive) '{max_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_ex=max_ex))

        if min_ex is not None and min_ex >= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than or equals to min limit(exclusive) '{min_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_ex=min_ex))
github Grokzen / pykwalify / pykwalify / core.py View on Github external
max_ex,
            min_ex,
            value,
            path,
        )

        if max_ is not None and max_ < value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than max limit '{max_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_=max_))

        if min_ is not None and min_ > value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_=min_))

        if max_ex is not None and max_ex <= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than or equals to max limit(exclusive) '{max_ex}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_ex=max_ex))

        if min_ex is not None and min_ex >= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
github Grokzen / pykwalify / pykwalify / core.py View on Github external
log.debug(
            u"Validate length : %s : %s : %s : %s : %s : %s",
            max, min, max_ex, min_ex, value, path,
        )

        if max_ is not None and max_ < value_length:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Value: '{value_str}' has length of '{value}', greater than max limit '{max_}'. Path: '{path}'",
                value_str=value,
                path=path,
                value=len(value),
                prefix=prefix,
                max_=max_))

        if min_ is not None and min_ > value_length:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Value: '{value_str}' has length of '{value}', greater than min limit '{min_}'. Path: '{path}'",
                value_str=value,
                path=path,
                value=len(value),
                prefix=prefix,
                min_=min_))

        if max_ex is not None and max_ex <= value_length:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Value: '{value_str}' has length of '{value}', greater than max_ex limit '{max_ex}'. Path: '{path}'",
                value_str=value,
                path=path,
                value=len(value),
                prefix=prefix,
                max_ex=max_ex))
github Grokzen / pykwalify / pykwalify / core.py View on Github external
def _check_int_timestamp_boundaries(timestamp):
            """
            """
            if timestamp < 1:
                # Timestamp integers can't be negative
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Integer value of timestamp can't be below 0",
                    path=path,
                    value=timestamp,
                    timestamp=str(timestamp),
                ))
            if timestamp > 2147483647:
                # Timestamp integers can't be above the upper limit of
                # 32 bit integers
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Integer value of timestamp can't be above 2147483647",
                    path=path,
                    value=timestamp,
                    timestamp=str(timestamp),
                ))
github Grokzen / pykwalify / pykwalify / core.py View on Github external
def _validate_scalar_type(self, value, t, path):
        """
        """
        log.debug(u" # Core scalar: validating scalar type : %s", t)
        log.debug(u" # Core scalar: scalar type: %s", type(value))

        try:
            if not tt[t](value):
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Value '{value}' is not of type '{scalar_type}'. Path: '{path}'",
                    path=path,
                    value=unicode(value) if tt['str'](value) else value,
                    scalar_type=t))
                return False
            return True
        except KeyError as e:
            # Type not found in valid types mapping
            log.debug(e)
            raise CoreError(u"Unknown type check: {0!s} : {1!s} : {2!s}".format(path, value, t))
github Grokzen / pykwalify / pykwalify / core.py View on Github external
"""
        if not isinstance(value, int) and not isinstance(value, float):
            raise CoreError("Value must be a integer type")

        log.debug(
            u"Validate range : %s : %s : %s : %s : %s : %s",
            max_,
            min_,
            max_ex,
            min_ex,
            value,
            path,
        )

        if max_ is not None and max_ < value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', greater than max limit '{max_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    max_=max_))

        if min_ is not None and min_ > value:
                self.errors.append(SchemaError.SchemaErrorEntry(
                    msg=u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'",
                    path=path,
                    value=nativestr(value) if tt['str'](value) else value,
                    prefix=prefix,
                    min_=min_))

        if max_ex is not None and max_ex <= value:
                self.errors.append(SchemaError.SchemaErrorEntry(
github Grokzen / pykwalify / pykwalify / core.py View on Github external
# If a date_format is specefied then use strptime on all formats
            # If no date_format is specefied then use dateutils.parse() to test the value
            log.debug(date_formats)

            if date_formats:
                # Run through all date_formats and it is valid if atleast one of them passed time.strptime() parsing
                valid = False
                for date_format in date_formats:
                    try:
                        time.strptime(date_value, date_format)
                        valid = True
                    except ValueError:
                        pass

                if not valid:
                    self.errors.append(SchemaError.SchemaErrorEntry(
                        msg=u"Not a valid date: {value} format: {format}. Path: '{path}'",
                        path=path,
                        value=date_value,
                        format=date_format,
                    ))
                    return
            else:
                try:
                    parse(date_value)
                except ValueError:
                    self.errors.append(SchemaError.SchemaErrorEntry(
                        msg=u"Not a valid date: {value} Path: '{path}'",
                        path=path,
                        value=date_value,
                    ))
        elif isinstance(date_value, (datetime.date, datetime.datetime)):
github Grokzen / pykwalify / pykwalify / core.py View on Github external
path=path,
                value=len(value),
                prefix=prefix,
                max_=max_))

        if min_ is not None and min_ > value_length:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Value: '{value_str}' has length of '{value}', greater than min limit '{min_}'. Path: '{path}'",
                value_str=value,
                path=path,
                value=len(value),
                prefix=prefix,
                min_=min_))

        if max_ex is not None and max_ex <= value_length:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Value: '{value_str}' has length of '{value}', greater than max_ex limit '{max_ex}'. Path: '{path}'",
                value_str=value,
                path=path,
                value=len(value),
                prefix=prefix,
                max_ex=max_ex))

        if min_ex is not None and min_ex >= value_length:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Value: '{value_str}' has length of '{value}', greater than min_ex limit '{min_ex}'. Path: '{path}'",
                value_str=value,
                path=path,
                value=len(value),
                prefix=prefix,
                min_ex=min_ex))