Quick schema validator.
Project description
Installing
pip3 install shucks
Simple Usage
Validating a login form accepting email or phone and a password.
import shucks
import math
schema = shucks.And(
dict,
{
'id': shucks.If(
shucks.And(str, lambda v: '@' in v),
shucks.Con(
lambda v: v.split('@', 1)[1],
shucks.contain({'gmail.com', 'hotmail.com', 'yahoo.com'})
),
shucks.And(
shucks.Or(str, int),
shucks.Con(str, shucks.Con(len, shucks.range(10, 10)))
)
),
'password': shucks.And(
str,
shucks.Con(len, shucks.And(shucks.range(8, math.inf))),
shucks.wrap(shucks.Not(lambda v: 'logo' in v), 'logo')
),
shucks.Opt('remember'): bool
}
)
data = {
'id': 1234567890
'password': 'logo1234'
}
shucks.check(schema, data)
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shucks-1.2.1.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file shucks-1.2.1.tar.gz
.
File metadata
- Download URL: shucks-1.2.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5530b8475706e653455615b59a7e1991bb2d172a75b46216e527dd41ef7829e3 |
|
MD5 | 9d5c570bc7662f89be38e455d23fb1cd |
|
BLAKE2b-256 | ad2e49870fefd09666d33aa127a71c407fabef219ae60073076cf2677d175a30 |
File details
Details for the file shucks-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: shucks-1.2.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e6f4ac791d76abde5ae2e9aa6e298e012980e347dd49c09ff39def34e9ab12a |
|
MD5 | ace9098916407e99edfbafe5beb575b9 |
|
BLAKE2b-256 | f5f8282362654d3881108fcefe213b89db482bf09bb88f898bab8c0f241a1833 |