Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Release version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Maslov committed Jul 3, 2016
0 parents commit 42ea7f4
Show file tree
Hide file tree
Showing 16 changed files with 1,070 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
dist/
*.egg-info/
__pycache__/
.tox/

*.py[codw]
.coverage
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: python
python:
- "3.4"
install: "pip install -r dev-requirements.txt"
script: nosetests --with-coverage --cover-erase --cover-package=gateguard
after_success:
- coveralls
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Vitalii Maslov (https://pyvim.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Gateguard #
*Schema-based validation package*

[![Build Status](https://travis-ci.org/pyvim/gateguard.svg)](https://travis-ci.org/pyvim/gateguard)
[![Coverage Status](https://coveralls.io/repos/github/pyvim/gateguard/badge.svg?branch=master)](https://coveralls.io/github/pyvim/gateguard?branch=master)
[![PyPI](http://img.shields.io/pypi/v/gateguard.svg?style=flat)](https://pypi.python.org/pypi/gateguard)
[![Documentation Status](http://readthedocs.org/projects/gateguard/badge/?version=latest)](http://gateguard.readthedocs.org/en/latest/?badge=latest)

## Installation ##

`pip install gateguard`

## Usage ##

```python
from gateguard import Schema, IntegerField, StringField


class MySchema(Schema):

pk = IntegerField(min_value=1)
name = StringField(required=False)
surname = StringField(max_length=20)

data = {
'pk': 'p',
'name': 'Milli',
}

try:
MySchema.validate(data)
except MySchema.ValidationError as e:
print(e.error)

>>> {"pk": "Value must be a valid integer", "surname": "Value is required"}
```

## Documentation ##
[Read the Docs](http://gateguard.readthedocs.org/)

## Tests ##
```bash
tox
```

## Changelog ##
See [releases](https://github.com/pyvim/gateguard/releases)

## License ##
See [LICENSE](https://github.com/pyvim/gateguard/blob/master/LICENSE)
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=========
Gateguard
=========

Installation
------------
`pip install gateguard`

Documentation
-------------
`Read The Docs
<http://gateguard.readthedocs.org>`_

Source code
-----------
`Github
<https://github.com/pyvim/gateguard>`_
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage
coveralls
tox
nose
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: Gateguard
next_url: install.html
next_title: Installation
prev_title: Table of Contents
prev_url: siteindex.html

# Gateguard #

Package for transform data.

See the [installation instructions](install) to get started.

## Support ##

You may ask for help and discuss various other issues on the [bug tracker][].

[bug tracker]: http://github.com/pyvim/gateguard/issues
16 changes: 16 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: Installation
prev_title: Index
prev_url: index.html
next_title: Reference
next_url: reference.html

# Installing Gateguard #

The easiest way to install Gateguard is simply to type the
following command from the command line:

```bash
pip install gateguard
```

You're ready to [use](reference) Gateguard.
31 changes: 31 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
title: Reference
prev_title: Installation
prev_url: install


# Using Gateguard #

## The Basics ##

```python
from gateguard import Schema, IntegerField, StringField


class MySchema(Schema):

pk = IntegerField(min_value=1)
name = StringField(required=False)
surname = StringField(max_length=20)

data = {
'pk': 'p',
'name': 'Milli',
}

try:
MySchema.validate(data)
except MySchema.ValidationError as e:
print(e.error)

>>> {"pk": "Value must be a valid integer", "surname": "Value is required"}
```
36 changes: 36 additions & 0 deletions gateguard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# coding=utf-8

from .fields import (
BooleanField,
StringField,
IntegerField,
FloatField,
ChoiceField,
ArrayField,
MultipleChoiceField,
URLField,
RegexMatchField,
HostField,
SlugField,
MapField
)
from .schema import Schema
from .exceptions import ValidationError


__all__ = (
'BooleanField',
'StringField',
'IntegerField',
'FloatField',
'ChoiceField',
'ArrayField',
'MultipleChoiceField',
'URLField',
'RegexMatchField',
'HostField',
'SlugField',
'MapField',
'Schema',
'ValidationError',
)
14 changes: 14 additions & 0 deletions gateguard/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# coding=utf-8


class GateguardError(Exception):

pass


class ValidationError(GateguardError):

def __init__(self, error=None):
self.error = error

super().__init__(self.error)

0 comments on commit 42ea7f4

Please sign in to comment.