About Validatish

Validatish is a validating library, initially built to support the Formish forms library.

How does Validatish work?

Validatish is split into two main section, validate and validator. Validate is a set of functions that raise exceptions on failure and validator is a class wrapper around the validate library that also adds composite validators.

The Validate Module

Validate implements the following validators..

validatish.validate.is_required(v)
Checks the non_zero attribute but allows numberic zero to pass
validatish.validate.is_string(v)
checks that the value is an instance of basestring
validatish.validate.is_plaintext(v, extra='')

Checks that the value contains only alpha-numberics

Parameters:
  • extra – A list of extra characters that are allowed
validatish.validate.is_integer(v)
Checks that the value can be converted into an integer
validatish.validate.is_number(v)
Checks that the value is not a string but can be converted to a float
validatish.validate.is_email(v)
Validate the value looks like an email address.
validatish.validate.is_url(v, with_scheme=False)
Uses a simple regex from FormEncode to check for a url
validatish.validate.is_equal(v, compared_to)

Check the value, v, is equal to the comparison value.

Parameters:
  • compared_to – the value to compare to
validatish.validate.is_one_of(v, set_of_values)

Check that the value is one of the set of values given

Parameters:
  • set_of_values – the set of values to check against
validatish.validate.has_length(v, min=None, max=None)

Check that the length of the string or sequence is not less than an optional min value and not greater than an optional max value

Parameters:
  • max – optional max value
  • min – optional min value
validatish.validate.is_in_range(v, min=None, max=None)

Check that the value is not less than an optional min value and not greater than an optional max value

Parameters:
  • max – optional max value
  • min – optional min value

The Validate Module

Validators implements the following validator classes

class validatish.validator.Required
Checks that the value is not empty
class validatish.validator.String
Checks whether value can be converted to an integer
class validatish.validator.PlainText(extra='')
Checks whether value is a ‘simple’ string
class validatish.validator.Email
Checks whether value looks like an email address.
class validatish.validator.URL(with_scheme=False)
Checks whether value is a url
class validatish.validator.Integer
Checks whether value can be converted to an integer
class validatish.validator.Number
Checks whether value can be converted to a number and is not a string
class validatish.validator.Equal(compared_to)
Validator that checks a value is equal to the comparison value, equal_to.
class validatish.validator.OneOf(set_of_values)
Checks whether value is one of a supplied list of values
class validatish.validator.Length(min=None, max=None)
Check whether the length of the value is not outside min/max bound(s)
class validatish.validator.Range(min=None, max=None)
Check whether the value is not outside min/max bound(s)
class validatish.validator.Any(*args)
Combines multiple validators together, raising an exception if any fail
class validatish.validator.All(*args)
Combines multiple validators together, raising an exception if they all fail
class validatish.validator.Always

A validator that always passes, mostly useful as a default.

This validator tests False to make it seem “invisible” to discourage anyone bothering actually calling it.