Simple model validations for Elixir and Sqlalchemy
Project description
SQLAlchemy and Elixir validations
=================================
Provide a set of simple yet useful validations for the models:
Sqlalchemy:
-----------
from sqlalchemy_validations import *
people_table = Table(....)
class Person(object)
pass
mapper(Person, people_table,
extension=[Validator(
range_of('age', 0, 150),
format_of('phone', re.compile(r'\d{4}-?\d{4}'))
numericality_of('foo','bar','some_next_field')
)
]
)
Elixir:
-------
from elixir_validations import *
class Person(Entity):
username=Field(Unicode(30),nullable=False,index=True)
email=Field(Unicode,nullable=False)
age=Field(Integer,nullable=False)
validates_uniqueness_of('username')
validates_presence_of('username', 'email')
validates_format_of('email',re.compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"))
validates_numericality_of('age',integer_only = True)
=================================
Provide a set of simple yet useful validations for the models:
Sqlalchemy:
-----------
from sqlalchemy_validations import *
people_table = Table(....)
class Person(object)
pass
mapper(Person, people_table,
extension=[Validator(
range_of('age', 0, 150),
format_of('phone', re.compile(r'\d{4}-?\d{4}'))
numericality_of('foo','bar','some_next_field')
)
]
)
Elixir:
-------
from elixir_validations import *
class Person(Entity):
username=Field(Unicode(30),nullable=False,index=True)
email=Field(Unicode,nullable=False)
age=Field(Integer,nullable=False)
validates_uniqueness_of('username')
validates_presence_of('username', 'email')
validates_format_of('email',re.compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"))
validates_numericality_of('age',integer_only = True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for sqlalchemy_elixir_validations-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07cd30f686ccb53a33da0c2e5b603ac06c1babcaa2dfa2bd1e232fdeb0d9ae4e |
|
MD5 | b87d891d87ac55f4a0591b05ee3274ac |
|
BLAKE2b-256 | 566bb7a644059a857897134d641211ad6d7fe743cb649ae576121975e65a74b8 |