# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['valley',
 'valley.contrib',
 'valley.tests',
 'valley.tests.examples',
 'valley.utils']

package_data = \
{'': ['*']}

install_requires = \
['envs>=1.3,<2.0']

setup_kwargs = {
    'name': 'valley',
    'version': '1.5.7',
    'description': 'Python extensible schema validations and declarative syntax helpers.',
    'long_description': '![alt text](https://s3.amazonaws.com/capless/images/valley-small.png "Valley - Extensible Schema Validations and Declarative Syntax Helpers")\n\n# Valley\n\nPython extensible schema validations and declarative syntax helpers.\n\n[![Unittests](https://github.com/capless/valley/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/capless/valley/actions/workflows/main.yml)\n\n## Installation\n\n`pip install valley`\n\n## Getting Started\n\n```python\nclass Animal(Schema):\n    name = CharProperty(required=True)\n    species = CharProperty(required=True)\n    color = CharProperty(required=True)\n    meal_type = CharProperty()\n    age = IntegerProperty(required=True)\n    \nfrog = Animal(name=\'Kermit\',species=\'frog\',color=\'green\',meal=\'carnivore\',age=1)\nfrog.validate()\n```\n\n#### Python Versions\n\nPython 3.6+\n\n- [Projects using Valley](#projects-using-valley)\n- [Schema and Declarative Syntax Helpers](#schema-and-declarative-syntax-helpers)\n- [Properties](#properties)\n- [JSON Encoders and Decoder](#json-encoders-and-decoder)\n\n### Projects Using Valley\n\n- [kev](https://github.com/capless/kev) - **K.E.V.** (Keys, Extra Stuff, and Values) is a Python ORM for key-value stores. Currently supported backends are Redis, S3, DynamoDB, and a S3/Redis hybrid backend.\n- [formy](https://github.com/capless/formy) - **Formy** is a Python forms library with Jinja2 templates\n\n\n### Schema and Declarative Syntax Helpers\n\nThe schema class **[(valley.contrib.Schema)](https://github.com/capless/valley/blob/master/valley/contrib/__init__.py)** provides the model for validating properties. Valley also includes utilities **[(valley.declarative)](https://github.com/capless/valley/blob/master/valley/declarative.py)** to make building declarative syntax validation libraries easier. See an example below. \n \n```python\nfrom six import with_metaclass\n\nfrom valley.declarative import DeclaredVars as DV, \\\n    DeclarativeVariablesMetaclass as DVM\nfrom valley.schema import BaseSchema\nfrom valley.properties import *\n\n\nclass DeclaredVars(DV):\n    base_field_class = BaseProperty\n    base_field_type = \'_base_properties\'\n\n\nclass DeclarativeVariablesMetaclass(DVM):\n    declared_vars_class = DeclaredVars\n\n\nclass Schema(with_metaclass(DeclarativeVariablesMetaclass, BaseSchema)):\n    _create_error_dict = False\n    BUILTIN_DOC_ATTRS = []\n    \n#If you just want to build upon an existing schema use valley.contrib.Schema\n\nclass Animal(Schema):\n    name = CharProperty(required=True)\n    species = CharProperty(required=True)\n    color = CharProperty(required=True)\n    meal_type = CharProperty()\n    age = IntegerProperty(required=True)\n```\n\n```python  \n>>bear = Animal(name="Yogi",species="bear",color="brown",meal_type="carnivore",age=5)\n>>bear.is_valid\nFalse\n>>bear.validate()\n>>bear.is_valid\nTrue\n>>frog = Animal(name="Kermit",species="frog",color="green",meal_type="carnivore")\n>>frog.is_valid\nFalse\n>>frog.validate()\n\nValidationException                       Traceback (most recent call last)\n\n      1 frog = Animal(name=\'Frog\',color=\'Green\',meal_type=\'carnivore\')\n      2 \n      3 frog.validate()\n\n/home/coder/workspace/valley/valley/schema.pyc in validate(self)\n     55                     self._errors[key] = e.error_msg\n     56                 else:\n     57                     raise e\n     58             value = prop.get_python_value(data.get(key))\n     59             data[key] = value\n\nValidationException: age: This value is required\n```\n\n### Properties\n\n#### BaseProperty\n\nBase class that all of the following properties are subclassed from.\n\n##### Default Validators\n\n- RequiredValidator (if the required kwarg is set)\n\n#### CharProperty\n\nValidates that the input is a string type. \n\n##### Example\n\n```python\nfrom valley.properties import CharProperty\n\nfirst_name = CharProperty(required=True,min_length=1,max_length=20)\nfirst_name.validate(\'Some string\',\'First Name\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- StringValidator\n- MinLengthValidator (if min_length kwarg is set)\n- MaxLengthValidator (if max_length kwarg is set)\n\n#### SlugProperty\n\nValidates that the input is a string type but is also a slug (ex. this-is-a-slug). \n\n##### Example\n\n```python\nfrom valley.properties import SlugProperty\n\nslug = SlugProperty(required=True,min_length=1,max_length=20)\nslug.validate(\'some-slug\',\'Slug\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- StringValidator\n- MinLengthValidator (if min_length kwarg is set)\n- MaxLengthValidator (if max_length kwarg is set)\n- SlugValidator\n\n#### EmailProperty\n\nValidates that the input is a string type but is also in valid email format. \n\n##### Example\n\n```python\nfrom valley.properties import EmailProperty\n\nemail = EmailProperty(required=True,min_length=1,max_length=20)\nemail.validate(\'you@you.com\',\'Email\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- StringValidator\n- MinLengthValidator (if min_length kwarg is set)\n- MaxLengthValidator (if max_length kwarg is set)\n- EmailValidator\n\n\n#### IntegerProperty\n\nValidates that the input is a integer type.\n\n##### Example\n\n```python\nfrom valley.properties import IntegerProperty\n\nage = IntegerProperty(required=True,min_value=1,max_value=20)\nage.validate(5,\'Age\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- IntegerValidator\n- MinValuehValidator (if min_value kwarg is set)\n- MaxLengthValidator (if max_value kwarg is set)\n\n\n#### FloatProperty\n\nValidates that the input is a float type.\n\n##### Example\n\n```python\nfrom valley.properties import FloatProperty\n\ngpa = FloatProperty(required=True,min_value=1,max_value=20)\ngpa.validate(4.0,\'GPA\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- FloatValidator\n- MinValuehValidator (if min_value kwarg is set)\n- MaxLengthValidator (if max_value kwarg is set)\n\n#### BooleanProperty\n\nValidataes that the input is a bool type.\n\n##### Example\n\n```python\nfrom valley.properties import BooleanProperty\n\nactive = BooleanProperty()\nactive.validate(True,\'Active\')\n```\n##### Default Validators\n\n- Validators from BaseProperty\n- BooleanValidator\n\n#### DateProperty\n\nValidates that the input is a date object or a string that can be transformed to a date object.\n \n##### Example\n\n```python\nfrom valley.properties import DateProperty\n\nactive = DateProperty(required=True)\nactive.validate(\'2017-03-27\',\'Active\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- DateValidator\n\n\n#### DateTimeProperty\n\nValidates that the input is a datetime object or a string that can be transformed to a datetime object.\n\n##### Example\n\n```python\nfrom valley.properties import DateTimeProperty\n\nactive = DateTimeProperty(required=True)\nactive.validate(\'2017-03-03 12:00:00\',\'Active\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- DateTimeValidator\n\n#### DictProperty\n\nValidates that the input is a dict object. \n\n##### Example\n\n```python\nfrom valley.properties import DictProperty\n\nperson = DictProperty(required=True)\nperson.validate({\'first\':\'Eddie\',\'last\':\'Murphy\'},\'First Name\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- DictValidator\n\n#### ListProperty\n\nValidates that the input is a list object. \n\n##### Example\n\n```python\nfrom valley.properties import ListProperty\n\nschools = ListProperty(required=True)\nschools.validate([\'Jones School\',\'Edwards School\'],\'Schools\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- ListValidator\n\n#### ForeignProperty\n\nValidates that the input is an instance of another class\n\n##### Example\n\n```python\nfrom valley.properties import ForeignProperty\n\ndistrict = ForeignProperty(District,required=True)\ndistrict.validate(District(name=\'Durham\'),\'District\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- ForeignValidator\n\n#### ForeignListProperty\n\nValidates that the input is an instance of another class\n\n##### Example\n\n```python\nfrom valley.properties import ForeignListProperty\n\ngreat_schools = ForeignListProperty(School,required=True)\ngreat_schools.validate([School(name=\'Duke\'),School(name=\'Hampton University\')],\'Great Schools\')\n#Go Duke\nterrible_schools = ForeignListProperty(School,required=True)\nterrible_schools.validate([School(name=\'UNC\'),School(name=\'Howard\')],\'Terrible Schools\')\n```\n\n##### Default Validators\n\n- Validators from BaseProperty\n- ListValidator\n- ForeignListValidator\n\n\n### JSON Encoders and Decoder\n\n#### ValleyEncoder\n\nPaired with the json.dumps it parses through Schema objects and returns valid json.\n\n##### Example\n\n```python\nimport json\nfrom valley.utils.json_utils import ValleyEncoder\nfrom valley.contrib import Schema\nfrom valley.properties import *\n\nclass NameSchema(Schema):\n    _create_error_dict = True\n    name = CharProperty(required=True)\n\n    def __unicode__(self):\n        return self.name\n\n\nclass Breed(NameSchema):\n    pass\n\n\nclass Dog(NameSchema):\n    breed = ForeignProperty(Breed,required=True)\n\n\nclass Troop(NameSchema):\n    dogs = ForeignListProperty(Dog)\n    primary_breed = ForeignProperty(Breed)\n\n\n>>> cocker = Breed(name=\'Cocker Spaniel\')\n\n>>> cockapoo = Breed(name=\'Cockapoo\')\n\n>>> bruno = Dog(name=\'Bruno\',breed=cocker)\n\n>>> blitz = Dog(name=\'Blitz\',breed=cockapoo)\n\n>>> durham = Troop(name=\'Durham\',dogs=[bruno,blitz],primary_breed=cocker)\n\n>>> print(json.dumps(durham, cls=ValleyEncoder))\n{\n  "dogs": [\n    {\n      "breed": {\n        "name": "Cocker Spaniel",\n        "_type": "valley.tests.examples.schemas.Breed"\n      },\n      "name": "Bruno",\n      "_type": "valley.tests.examples.schemas.Dog"\n    },\n    {\n      "breed": {\n        "name": "Cockapoo",\n        "_type": "valley.tests.examples.schemas.Breed"\n      },\n      "name": "Blitz",\n      "_type": "valley.tests.examples.schemas.Dog"\n    }\n  ],\n  "primary_breed": {\n    "name": "Cocker Spaniel",\n    "_type": "valley.tests.examples.schemas.Breed"\n  },\n  "name": "Durham",\n  "_type": "valley.tests.examples.schemas.Troop"\n}\n```\n\n#### ValleyEncoderNoType\n\nSame as ValleyEncoder except it doesn\'t add _type attributes.\n\n##### Example\n\n```python\nimport json\nfrom valley.utils.json_utils import ValleyEncoderNoType\nfrom valley.contrib import Schema\nfrom valley.properties import *\n\nclass NameSchema(Schema):\n    _create_error_dict = True\n    name = CharProperty(required=True)\n\n    def __unicode__(self):\n        return self.name\n\n\nclass Breed(NameSchema):\n    pass\n\n\nclass Dog(NameSchema):\n    breed = ForeignProperty(Breed,required=True)\n\n\nclass Troop(NameSchema):\n    dogs = ForeignListProperty(Dog)\n    primary_breed = ForeignProperty(Breed)\n\n\n>>> cocker = Breed(name=\'Cocker Spaniel\')\n\n>>> cockapoo = Breed(name=\'Cockapoo\')\n\n>>> bruno = Dog(name=\'Bruno\',breed=cocker)\n\n>>> blitz = Dog(name=\'Blitz\',breed=cockapoo)\n\n>>> durham = Troop(name=\'Durham\',dogs=[bruno,blitz],primary_breed=cocker)\n\n>>> print(json.dumps(durham, cls=ValleyEncoderNoType))\n{\n  "dogs": [\n    {\n      "breed": {\n        "name": "Cocker Spaniel"\n      },\n      "name": "Bruno"\n    },\n    {\n      "breed": {\n        "name": "Cockapoo"\n      },\n      "name": "Blitz"\n    }\n  ],\n  "primary_breed": {\n    "name": "Cocker Spaniel"\n  },\n  "name": "Durham"\n}\n```\n\n#### ValleyDecoder\n\nPaired with the json.loads it create Schema objects from json\n\n##### Example\n\n```python\nimport json\n\nfrom valley.utils.json_utils import ValleyDecoder\n\njson_string = \'{\n  "dogs": [\n    {\n      "breed": {\n        "name": "Cocker Spaniel",\n        "_type": "valley.tests.examples.schemas.Breed"\n      },\n      "name": "Bruno",\n      "_type": "valley.tests.examples.schemas.Dog"\n    },\n    {\n      "breed": {\n        "name": "Cockapoo",\n        "_type": "valley.tests.examples.schemas.Breed"\n      },\n      "name": "Blitz",\n      "_type": "valley.tests.examples.schemas.Dog"\n    }\n  ],\n  "primary_breed": {\n    "name": "Cocker Spaniel",\n    "_type": "valley.tests.examples.schemas.Breed"\n  },\n  "name": "Durham",\n  "_type": "valley.tests.examples.schemas.Troop"\n}\'\n\n>>> durham = json.loads(json_string,cls=ValleyDecoder)\n<Troop: Durham >\n>>> durham.name\n\'Durham\n>>> durham.primary_breed.name\nCocker Spaniel\n\n```',
    'author': 'Brian Jinwright',
    'author_email': 'None',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://github.com/capless/valley',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
