Fields

class brink.fields.Field(pk=False, required=False, hidden=False)[source]

Field base class. All other fields inherit from this class, so usually you want to use one of the more specialized fields. However, there might be cases where you wanna store an arbitrary value that does not fit well into any other standard field, and in that case you could use Field to store any value.

show(data)[source]

All field values will be passed through this method before being rendered as json. Thus you can perform any desired modifications to the final output here.

treat(data)[source]

All field values will be passed through this method before being saved to the database. Thus, you can make any final modifications to the value here.

validate(data)[source]

Runs all field validators.

validate_required(data)[source]

Validates that a value is present if the field is required.

Types

class brink.fields.IntegerField(*args, **kwargs)[source]

IntegerField. Use to hold integers.

class brink.fields.CharField(*args, *, min_length=0, max_length=9223372036854775807, **kwargs)[source]

CharField holds a char sequence.

class brink.fields.PasswordField(*args, **kwargs)[source]

PasswordField is suitable for holding passwords (duh). Hides the value by default when rendered to json.

class brink.fields.BooleanField(*args, **kwargs)[source]

BooleanField is suitable to hold boolean values.

Errors

exception brink.fields.FieldError[source]

FieldError base class. All field errors inherit from this exception class.

exception brink.fields.FieldRequired[source]

Thrown whenever a required field is not provided.

exception brink.fields.FieldInvalidType[source]

Thrown whenever a value of an invalid type is provided to the field.

exception brink.fields.FieldInvalidLength[source]

Thrown when the provided value either is too short or too long.