Skip to main content

A simple validation module ,support regex

Project description

# validfilter

## 简单描述

一个用来验证数据格式的模块,已经加入了正则表达式的识别,后期会加入具体某个KEY的是否需要验证的标示.

注释: 其实以前是有想法把每个kv的验证加入http api的验证,后来觉得这样会造成过多的耦合,所以放弃了...

[更多validfilter的介绍](http://xiaorui.cc)

## 安装方法
方法1.
```
pip install validfilter
```

方法2
```
git clone git@github.com:rfyiamcool/validfilter.git
cd validfilter
python setup.py install
```

## 使用方法

```

#coding:utf-8
from validfilter import checkdata

template = {
'name': 'xiaorui',
'age': '.*',
'url' : 'http://.*',
'address': '\w*',
'pets': [
{
'name': 'ying',
'kind': '.*'
}
],
'parents': [{'name': '.*'}],
}

kid = {
'name': "fengyun from xiaorui.cc",
'age': 123,
'url' : 'http://xiaorui.cc',
'address': 'beijing',
'pets': [
{
'name': "liliying",
'kind': "nima",
},
],
'parents': [
{'name': "zhangbin"},
{'name': "liudehua"}
]
}

print checkdata(template, kid)
```

#### Run Result
```
python test.py
xiaorui fengyun from xiaorui.cc
http://.* http://xiaorui.cc
.* 123
.* zhangbin
.* liudehua
.* nima
ying liliying
\w* beijing
True
```

感谢使用,validfilter一开始是用来验证rest post api过来的表单,后来在各个分布式RPC系统中使用验证各方的数据准确性。

END... ...

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

validfilter-3.1.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file validfilter-3.1.tar.gz.

File metadata

  • Download URL: validfilter-3.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for validfilter-3.1.tar.gz
Algorithm Hash digest
SHA256 f609802f208a38db01f3f43c6127b5a0c2f01b4f1e3f79334b1ccb61d2ac4c5c
MD5 6b4deb60a0d50de8e0a931e9b9fca341
BLAKE2b-256 68107874e9b46dba4bfe6798f15828049b41b252ad05031e0459c64ff7ae0096

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page