Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
repos:
- repo: local
hooks:
- id: clicktypes
name: render clicktypes/__init__.py
entry: poetry run python -m clicktypes
language: system
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand Down Expand Up @@ -45,11 +53,14 @@ repos:
hooks:
- id: flake8
args: ["--max-line-length", "88", "--ignore=E501"]
- repo: local
language_version: python3.8
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: clicktypes
name: render clicktypes/__init__.py
entry: poetry run python -m clicktypes
language: system
pass_filenames: false
always_run: true
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: mypy
language_version: python3.8
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ Additional `click` parameter types are built on top of the `validators` library,
pip install click-validators
```

to perform `validators.eth_address()` validation, you need to install the `eth-hash>=0.7.0` package.
for `clicktypes.eth_address()` validation, additional package `eth-hash[pycryptodome]>=0.7.0` is required.

[![PyPI - eth-hash](https://img.shields.io/pypi/v/eth-hash?logo=pypi&logoColor=white&label=eth-hash[pycryptodome])](https://pypi.org/project/eth-hash/)

```cmd
pip install click-validators[crypto-eth-addresses]
pip install click-validators[eth]
```

## Usage
Expand All @@ -89,7 +89,7 @@ import clicktypes


@click.command(
help=clicktypes.email.__doc__.split("\n", maxsplit=1)[0],
help="validate email address",
)
@click.argument(
"email",
Expand All @@ -103,6 +103,23 @@ if __name__ == "__main__":
main()
```

### Example

```cmd
$ main.py fu@bar.com

valid email='fu@bar.com'
```

```cmd
$ main.py fu.bar.com

Usage: main.py [OPTIONS] EMAIL
Try 'main.py --help' for help.

Error: Invalid value for 'EMAIL': Invalid email='fu.bar.com'.
```

## Dependencies

[![PyPI - click](https://img.shields.io/pypi/v/click?logo=pypi&logoColor=white&label=click)](https://pypi.org/project/click/)
Expand Down
Loading