py-checker 1.2.0
Python Micro check library
License: MIT
Requires Python: >=3.6, <4
Keywords: python types check checker library

# py-checker
![build](https://github.com/arlenxuzj/py-checker/workflows/build/badge.svg)
[![codecov](https://codecov.io/gh/arlenxuzj/py-checker/branch/master/graph/badge.svg?token=VDUDB8OSQY)](https://codecov.io/gh/arlenxuzj/py-checker)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=arlenxuzj_py-checker&metric=alert_status&token=5a80fa5d00337af4f78442eed11f3a1d6bc4ecf0)](https://sonarcloud.io/dashboard?id=arlenxuzj_py-checker)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py-checker)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

A general-purpose check library for python. **This is a python implementation of part of [is.js](https://github.com/arasatasaygin/is.js)**.

## Installation

```shell script
pip install py-checker
```

## Usage

```python
from pychecker import checker

checker.integer(...)
checker.any.integer(...)
checker.all.integer(...)
```

## Type Checks

#### checker.integer(value: Any)

**Checks if the given value(s) type is integer**

interface: all, any

```python
checker.integer(123) => True

checker.integer(True) => False

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

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

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

### checker.float(value: Any)

**Checks if the given value(s) type is float**

interface: all, any

```python
checker.float(0.2) => True

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

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

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

### checker.boolean(value: Any)

**Checks if the given value(s) type is boolean**

interface: all, any

```python
checker.boolean(1) => False

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

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

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

### checker.string(value: Any)

**Checks if the given value(s) type is string**

interface: all, any

```python
checker.string('') => True

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

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

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

### checker.array(value: Any)

**Checks if the given value(s) type is list**

interface: all, any

```python
checker.array([1, 'a']) => True

checker.all.array(1, [1, 'a']) => False

checker.any.array([], 1) => True

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

### checker.dictionary(value: Any)

**Checks if the given value(s) type is dictionary**

interface: all, any

```python
checker.dictionary({}) => True

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

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

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

### checker.set(value: Any)

**Checks if the given value(s) type is set**

interface: all, any

```python
checker.set(set({})) => True

checker.set({}) => False

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

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

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

### checker.tuple(value: Any)

**Checks if the given value(s) type is tuple**

interface: all, any

```python
checker.tuple((1, 2)) => True

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

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

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

### checker.none(value: Any)

**Checks if the given value(s) type is None**

interface: all, any

```python
checker.none(None) => True

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

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

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

### checker.function(value: Any)

**Checks if the given value(s) type is function**

interface: all, any

```python
checker.function(foo) => True

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

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

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


## Todo
- [ ] Type Checks
    - [x] ~~checker.none~~
    - [x] ~~checker.function~~
    - [ ] checker.date
    - [ ] checker.sameType
    - [ ] checker.date
- [ ] Presence Checks
    - [ ] checker.empty
    - [ ] checker.truthy
    - [ ] checker.falsy
- [ ] String Checks
    - [ ] checker.uppercase
    - [ ] checker.lowercase
    - [ ] checker.capitalized
- [ ] Integer Checks
    - [ ] checker.even
    - [ ] checker.odd
    - [ ] checker.positive
    - [ ] checker.negative