Validators

Validator

class json_justify.validators.Validator(message=None)

This is core of each validator class

Parameters:message (str) – Message to be raised when any invalidation occours

Data

class json_justify.validators.Data(message=None)

This is Data field to check that weather data is provided or not

Parameters:message (str) – Message to be raised when any invalidation occours

Length

class json_justify.validators.Length(min_val=-1, max_val=-1, message=None)

This validator is used to check the minimum and maximum Length of data This will work with str, int , float not with array length

Parameters:
  • min_val (int) – minimum length
  • max_val (int) – maximum length
  • message (str) – Message to be raised when any invalidation occours

Email

class json_justify.validators.Email(message=None)

The Email Validator is used to validate Email which use dependency of python email_validator to validate email if not installed on machiene it will used standard regex to validate email

Parameters:message (str) – Message to be raised when any invalidation occours

URL

class json_justify.validators.URL(message=None)

The url validator is used to validate url’s But it dones not instanciate from Regex class here this is another implementation

Parameters:message (str) – Message to be raised when any invalidation occours

EqualTo

class json_justify.validators.EqualTo(field, message=None)

The EqualTo Validator is used to check if data in our field is same as other field

Parameters:
  • field (Field class) – Other field Pass the whole Field
  • message (str) – Message to be raised when any invalidation occours

Date

class json_justify.validators.Date(min_date=datetime.datetime(1, 1, 1, 0, 0), max_date=datetime.datetime(1, 1, 1, 0, 0), field_format=None, message=None)

The date field validator is used to validate date field under specific range of min_date and max_date

Parameters:
  • min_date (str of year-month-date) – minimum date
  • max_date (str of year-month-date) – maximum date
  • field_format (Field format %Y-%M-%d is default) – format of field
  • message (str) – message

Regex

class json_justify.validators.Regex(reg, message=None)

This is used to validate data in format of regex

Parameters:
  • regex (str) – regex
  • message (str) – Message to be raised when Error occours

Wrong

class json_justify.validators.Wrong(message=None)

This Validator is specific to boolean Field which validates that data is False only

Parameters:message (str) – message to be raise when error occours