Skip to content

Commit

Permalink
docs init
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotgao2 committed Mar 28, 2017
1 parent 65d4e5e commit ceebcc0
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ ENV/

# Rope project settings
.ropeproject
/docs/site/
1 change: 1 addition & 0 deletions docs/docs/custom_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## TODO
17 changes: 17 additions & 0 deletions docs/docs/data_types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## DataTypes

```python
from xdata.schema import Schema
from xdata.types import *

DataType(required=True,default='11',choices=[])

Str(length=11, max_length=12,min_length=10,regex="")
Int(max=10000,min=12)
Bool(max=10000,min=12)
Decimal(left=5,right=2)
DateTime(max_datetime='2001-01-01 00:00:00', min_datetime='2000-01-01 00:00:00')
Date(max_date='2001-01-01', min_date='2000-01-01')
Time(max_time='06:00:00', min_time='05:00:00')

```
17 changes: 17 additions & 0 deletions docs/docs/errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Errors

```python
from xdata.schema import Schema
from xdata.types import *

class UserSchema(Schema):
telephone = Str(length=11, required=True)
password = Str(min_length=8, max_length=16, required=True)


request_data = {}

schema = UserSchema(request_data)
if not schema.valid:
print(schema.errors) # {'telephone': 'telephone is required', 'password': 'password is required'}
```
17 changes: 17 additions & 0 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# XData

A simple but useful library for validating data.

## Features

- Easy to use, only one step
- Easy to extend
- No dependencies

## Required

python >= 3.5

## Installation

`pip install xdata`
20 changes: 20 additions & 0 deletions docs/docs/validate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Validate

```python
from xdata.schema import Schema
from xdata.types import *


class UserSchema(Schema):
telephone = Str(length=11, required=True)
password = Str(min_length=8,max_length=16, required=True)

request_data = {
'telephone':'18180050000',
'password':'idonotknow'
}

schema = UserSchema(request_data)
if schema.valid:
print(schema.validated_data) # {'telephone': '18180050000', 'password': 'idonotknow'}
```
15 changes: 15 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
site_name: XData

pages:
- Home: index.md
- Validate: validate.md
- Errors: errors.md
- DataTypes: data_types.md
- CustomData: custom_data.md

repo_name: 'GitHub'
repo_url: https://github.com/gaojiuli/xdata

site_author: gaojiuli

site_description: A simple but useful library for validating data.

0 comments on commit ceebcc0

Please sign in to comment.