Adds a conf module to define application settings. Each setting is defined with an Option class that includes built-in validators and is extendable to add more. Option initialization exposes the following kwargs:
default: to define the default value
allow_null: if None value is allowed or not
validators: a list of functions that are executed to validate option's value
Example
from elmo.conf.config import BaseConfig
class Settings(BaseConfig):
url = Option(default="http://example.com", allow_null=False)
home = Option()
dry_run = Option(validators=[is_boolean])
settings = Settings()
settings.is_valid() # executes all options validators
Overview
Closes #17
Adds a
conf
module to define application settings. Each setting is defined with anOption
class that includes built-in validators and is extendable to add more.Option
initialization exposes the following kwargs:default
: to define the default valueallow_null
: ifNone
value is allowed or notvalidators
: a list of functions that are executed to validate option's valueExample