一个仿 django form 的表单验证库
Project description
xlform
一个仿 django form 的表单验证库
Installation
pip install xlform
Example
from xlform.forms import Form
from xlform.fields import *
class NF(Form):
a = CharField(max_length=4, min_length=2, empty_value='123')
b = CharField(max_length=4, min_length=2, required=False, empty_value='222')
phone = PhoneField(max_length=11)
email = EmailField()
reg = RegexField(regex='^1[3456789]\d{9}$')
uuid = UUIDField(required=False)
boolean = BooleanField(required=False)
integer = IntegerField(max_value=11)
ft = FloatField(max_value=12)
dc = DecimalField(max_digits=3, decimal_places=1, required=False)
data = {
# 'a': '12',
'b': '123',
'phone': '16666666666',
'email': '16666666666@qq.com',
'reg': '16666666666',
'uuid': '998a281c-e257-11e8-b428-8c85904e5604',
'boolean': 0,
'integer': '11',
'ft': '11.1111',
'dc': 11.0
}
nf = NF(data)
if nf.is_valid():
print(nf.cleaned_data)
else:
print(nf.errors)
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
xlform-0.1.4.tar.gz
(5.4 kB
view details)
File details
Details for the file xlform-0.1.4.tar.gz.
File metadata
- Download URL: xlform-0.1.4.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
449aee449e4126a4f2a7a5b27cd3511b773a53bc2788f4f82a1318f8e5e9c854
|
|
| MD5 |
648b495e5af8ecac9826184c76b3f2f7
|
|
| BLAKE2b-256 |
22f16b7317313a0c51a90a0a9cbea640add8880e166d14211e60046c312c1012
|