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


Release history Release notifications

This version
History Node

3.1

History Node

3.0

History Node

2.0

History Node

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
validfilter-3.1.tar.gz (3.0 kB) Copy SHA256 hash SHA256 Source None Sep 6, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page