diff --git a/docs/cleaners.rst b/docs/cleaners.rst index afec238..25dbb27 100644 --- a/docs/cleaners.rst +++ b/docs/cleaners.rst @@ -6,8 +6,8 @@ Cleaners Cleaner classes for cleaning input before conversion and validation. -Cleaners --------- +Creating Cleaners +----------------- Cleaner classes inherit from the Cleaner metaclass. They must be callable, with the __call__ dunder method taking one parameter, the value. An example of a cleaner to change the input value to lower @@ -22,17 +22,16 @@ case looks like:: result = value.lower() return result +Cleaners +-------- - -.. autoclass:: LowerCleaner +.. autoclass:: cooked_input.StripCleaner .. autoclass:: cooked_input.LowerCleaner -.. autoclass:: UpperCleaner - -.. autoclass:: CapitalizeCleaner +.. autoclass:: cooked_input.UpperCleaner -.. autoclass:: StripCleaner +.. autoclass:: cooked_input.CapitalizeCleaner -.. autoclass:: ReplaceCleaner +.. autoclass:: cooked_input.ReplaceCleaner diff --git a/docs/convertors.rst b/docs/convertors.rst index 65dd0dd..be6b320 100644 --- a/docs/convertors.rst +++ b/docs/convertors.rst @@ -7,8 +7,8 @@ Convertors classes for converting the string input to the desired output. Conver validation. -Convertors ----------- +Creating Convertors +------------------- Convertor classes inherit from the Convertor metaclass. They must be callable, with the __call__ dunder method taking one parameter, the value. An example of a convertor to change the input value to an integer @@ -28,18 +28,21 @@ looks like:: def __repr__(self): return 'IntConvertor(base=%d, value_error_str=%s)' % (self._base, self.value_error_str) -.. autoclass:: IntConvertor +Convertors +---------- + +.. autoclass:: cooked_input.IntConvertor -.. autoclass:: FloatConvertor +.. autoclass:: cooked_input.FloatConvertor -.. autoclass:: BooleanConvertor +.. autoclass:: cooked_input.BooleanConvertor -.. autoclass:: ListConvertor +.. autoclass:: cooked_input.ListConvertor -.. autoclass:: DateConvertor +.. autoclass:: cooked_input.DateConvertor -.. autoclass:: YesNoConvertor +.. autoclass:: cooked_input.YesNoConvertor -.. autoclass:: TableConvertor +.. autoclass:: cooked_input.TableConvertor diff --git a/docs/get_input.rst b/docs/get_input.rst index a6e17d4..e3c765f 100644 --- a/docs/get_input.rst +++ b/docs/get_input.rst @@ -23,7 +23,6 @@ get_table_input validate -------- - .. autofunction:: cooked_input.validate process_value diff --git a/docs/validators.rst b/docs/validators.rst index 574ba71..28a8862 100644 --- a/docs/validators.rst +++ b/docs/validators.rst @@ -16,21 +16,19 @@ for more information on validus see: https://github.com/shopnilsazal/validus -Validators ----------- +Creating Validators +------------------- Validator classes inherit from the Validator metaclass. They must be callable, with the __call__ dunder method taking one parameter, the value. An example of a validator to verify that the input is exactly a specified length looks like:: class ExactLengthValidator(Validator): - # check a value is exactly a length def __init__(self, length=None, **kwargs): self._length = length super(ExactLengthValidator, self).__init__(**kwargs) def __call__(self, value): - # TypeError thrown if value does not implement __len__ val_len = len(value) condition1 = (self._length is None or val_len == self._length) return True if condition1 else False @@ -39,28 +37,25 @@ a specified length looks like:: return 'ExactLengthValidator(value=%s)' % (self._length) -.. autoclass:: ExactLengthValidator - -.. autoclass:: InLengthValidator - -.. autoclass:: ExactValueValidator +Validators +---------- -.. autoclass:: InRangeValidator +.. autoclass:: cooked_input.ExactLengthValidator -.. autoclass:: InChoicesValidator +.. autoclass:: cooked_input.InLengthValidator -.. autoclass:: NotInValidator +.. autoclass:: cooked_input.ExactValueValidator -.. autoclass:: InAnyValidator +.. autoclass:: cooked_input.InRangeValidator -.. autoclass:: RegexValidator +.. autoclass:: cooked_input.InChoicesValidator -.. autoclass:: PasswordValidator +.. autoclass:: cooked_input.NotInValidator -.. autoclass:: ListValidator +.. autoclass:: cooked_input.InAnyValidator -helper functions: ------------------ +.. autoclass:: cooked_input.RegexValidator -.. autofunction:: validate +.. autoclass:: cooked_input.PasswordValidator +.. autoclass:: cooked_input.ListValidator