Fields

Field

class json_justify.fields.Field(field_name, validators=None)

This Field Class is Core of all the Fields and should be instanciated For Creating New Fields This should only be used with JsonManager Field Following Things should be done in order to Create Field – Instanciate Field – Should implement _validate() function to which data of field will be provided Also one can change whole functionality by instanciating Field object as well

Parameters:
  • field_name (str) – Name of the field same as JsonManager Class Field
  • validators (list of callable take one param data) – list of validators
data
Returns:data associated with particular field
Raises:Invalid Exception on delete of these property
register_error(key, value)

This Function is used to register error of the fields which is usually done by the validaors to register errors

Parameters:
  • key – key of error for json
  • value – custom error message inside json
Returns:

None but registors error

String

class json_justify.fields.String(field_name, validators=None)

This is simple String Field of json Which should be used with json manager class

This field is automacally called inside JsonManager Class and validated if Invalid data is raised it will automatically catched by JsonManager Class

Parameters:
  • field_name (str) – Name of the field same as JsonManager Class Field
  • validators (list of callable take one param data) – list of validators

Number

class json_justify.fields.Number(field_name, validators=None)

This is Number Field and Should be Used inside JsonManager Class to create numbers

This field will raise Invalid and automatically catched by JsonManager if Data to key is not int of float

Parameters:
  • field_name (str) – Name of the field same as JsonManager Class Field
  • validators (list of callable take one param data) – list of validators

Boolean

class json_justify.fields.Boolean(field_name, validators=None)

This is Boolean Field and Should be Used inside JsonManager Class to create numbers

This field will raise Invalid and automatically catched by JsonManager if Data to key is not Boolean

Parameters:
  • field_name (str) – Name of the field same as JsonManager Class Field
  • validators (list of callable take one param data) – list of validators

Array

class json_justify.fields.Array(field_name, min_len=-1, max_len=-1, js_model=None, validators=None, seq_validators=None)

This is simple Array Field and should be used with JsonManager Class to create simple Arrays and also objects inside array

Only one of three paremeters from js_model, validators, seq_validators can be choosed at a time Two Dimentional or N-Dimentional Array May be Implemented inside later Version of This

Parameters:
  • field_name (str) – Name of the field same as JsonManager Class Field
  • validators (list of callable take one param data) – list of validators
  • js_model – a JsonManager Class that should be used to create array of key json
  • seq_validators – A sequence of validators to validate each sequence of validator

if choosed length of array is seq_validator