Skip to main content

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)

Project details


Download files

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

Source Distribution

sqlalchemy_elixir_validations-0.1.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page