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 hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page