Skip to content

formats: consider add INTEGER_SCHEMA and FLOAT_SCHEMA #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dentrax opened this issue Aug 3, 2021 · 1 comment
Closed

formats: consider add INTEGER_SCHEMA and FLOAT_SCHEMA #367

Dentrax opened this issue Aug 3, 2021 · 1 comment
Labels
legacy Issues related to legacy interfaces (obsolete with #731)

Comments

@Dentrax
Copy link

Dentrax commented Aug 3, 2021

Description of issue or feature request:

It would be great if we have the INTEGER_SCHEMA and FLOAT_SCHEMA formats. We can use these schemas in order the validate whether the given content is in integer or float format.

Actually, there is already an Integer class in the schema file, we can easily use this:

def check_match(self, object):
    if isinstance(object, bool) or not isinstance(object, int):
      # We need to check for bool as a special case, since bool
      # is for historical reasons a subtype of int.
      raise exceptions.FormatError(
          'Got ' + repr(object) + ' instead of an integer.')

At the end of the day, this is what will we have:

ANY_INTEGER_SCHEMA = SCHEMA.AnyInteger()
ANY_FLOAT_SCHEMA = SCHEMA.AnyFloat()
@lukpueh lukpueh added the legacy Issues related to legacy interfaces (obsolete with #731) label Mar 14, 2024
@lukpueh
Copy link
Member

lukpueh commented Apr 16, 2024

obsolete via #776

@lukpueh lukpueh closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy Issues related to legacy interfaces (obsolete with #731)
Projects
None yet
Development

No branches or pull requests

2 participants