Skip to main content

Python Micro check library

Project description

py-check

A general-purpose check library for python. This is a python implementation of part of is.js.

Installation

pip install py-check

Usage

from pycheck import check

check.integer(...)
check.any.integer(...)
check.all.integer(...)

Type Checks

check.integer(value: Any)

Checks if the given value(s) type is integer

interface: all, any

check.integer(123) => True

check.integer(True) => False

check.all.integer(1, 'a') => False

check.any.integer(1, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.integer([1, 2, 3]) => True

check.float(value: Any)

Checks if the given value(s) type is float

interface: all, any

check.float(0.2) => True

check.all.float(0.2, math.inf) => True

check.any.float(0.2, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.float([1.1, 1.2, 2]) => False

check.boolean(value: Any)

Checks if the given value(s) type is boolean

interface: all, any

check.boolean(1) => False

check.all.boolean(True, 1) => False

check.any.boolean(False, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.boolean([True, False]) => True

check.string(value: Any)

Checks if the given value(s) type is string

interface: all, any

check.string('') => True

check.all.string(True, 'a') => False

check.any.string(False, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.string(['True', '1']) => True

check.list(value: Any)

Checks if the given value(s) type is list

interface: all, any

check.list([1, 'a']) => True

check.all.list(1, [1, 'a']) => False

check.any.list([], 1) => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.list([1, [1, 2, 3]]) => False

check.dictionary(value: Any)

Checks if the given value(s) type is dictionary

interface: all, any

check.dictionary({}) => True

check.all.dictionary({'a': 1}, 'a') => False

check.any.dictionary({'a': 1}, 'a')

# 'all' and 'any' interfaces can also take argument of list type
check.all.dictionary([{'a': 1}, 'a']) => False

check.set(value: Any)

Checks if the given value(s) type is set

interface: all, any

check.set(set({})) => True

check.set({}) => False

check.all.set({1, 2, 3}, [1, 2, 3]) => False

check.any.set({1 ,2, 3}, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.set([{1, 2, 3}, [1, 2, 3]]) => False

check.tuple(value: Any)

Checks if the given value(s) type is tuple

interface: all, any

check.tuple((1, 2)) => True

check.all.tuple({1, 2}, (1, 2)) => False

check.any.tuple((), 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.tuple([{1, 2}, (1, 2)]) => False

check.none(value: Any)

Checks if the given value(s) type is None

interface: all, any

check.none(None) => True

check.all.none({1, 2}, None) => False

check.any.none(None, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.none([{1, 2}, None]) => False

check.function(value: Any)

Checks if the given value(s) type is function

interface: all, any

check.function(foo) => True

check.all.function({1, 2}, foo) => False

check.any.function(foo, 'a') => True

# 'all' and 'any' interfaces can also take argument of list type
check.all.function([{1, 2}, foo]) => False

Todo

  • Type Checks
    • check.date
    • check.sameType
  • Presence Checks
    • check.empty
    • check.truthy
    • check.falsy
  • String Checks
    • check.uppercase
    • check.lowercase
    • check.capitalized
  • Integer Checks
    • check.even
    • check.odd
    • check.positive
    • check.negative

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-check-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

py_check-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file py-check-1.0.0.tar.gz.

File metadata

  • Download URL: py-check-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for py-check-1.0.0.tar.gz
Algorithm Hash digest
SHA256 45fd57980f850c1d24f3f0d9b51f5adf8fde3b1c306cb2a7d8d53fba962ed890
MD5 5bf9b81fdcd0a6a4ec0ea20bc8002d1b
BLAKE2b-256 9c84d9ea52f53a20ac860c46ada1668e28b3b122b1573a2cd87593944253cee0

See more details on using hashes here.

File details

Details for the file py_check-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_check-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for py_check-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23c127c64926f6e229cbe8f77ca1ae139cd2011ca9db0c37e845a7c99d00a9c4
MD5 d9750fdc8768d9ac2b56e49af765c87f
BLAKE2b-256 be9d1c4c65940175a09ed711ffce9a3c9639d85e5af9f305d6d60ba0d240dfb8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page