PWeb DTO (API) Or Form (SSR) Manual
DTO stands for Data Transfer Object. Used for REST API data validation, serialization and deserialization.
Form used for Server Side Rendering Application, it’s responsible for form data validation, serialization and deserialization.
PWeb DTO or Form Fields Type
Type | Description |
---|---|
String | A string field, can contain character, number, word, sentence |
An email field. | |
Boolean | A boolean field. True/False data |
Integer | An integer field, can contain number without fraction. |
Decimal | Decimal number with rounding facilities |
Float | Double precision string. |
Number | |
Date | Formatted date string. |
Time | A formatted time string. |
DateTime | A formatted datetime string. |
Dict | A dict field. |
List | A list field |
Function | A field that takes the value returned by a function. |
Method | A field that takes the value returned by a Schema method. |
IP | A IP address field. |
Nested | Allows to nest a Schema inside a field. |
URL | An URL field. |
UUID | A UUID field. |
PWeb DTO or Form Fields common args
Name | Value | Default | Description |
---|---|---|---|
required | True/False | False | Raise a ValidationError if the field value is not supplied during deserialization. |
allow_none | True/None | None | Field Missing / Allow empty value if it True |
load_only | True/False | False | If set True, skip this field during serialization, otherwise its value will be present in the serialized data. |
dump_only | True/False | False | If set True, skip this field during deserialization, otherwise its value will be present in the deserialized object. |
dump_default | any | If set, this value will be used during serialization if the input value is missing. If not set, the field will be excluded from the serialized output if the input value is missing. | |
load_default | any | Default deserialization value for the field if the field is not found in the input data. | |
error_messages | Dict[str, str] | None | Overrides for Field.default_error_messages. |
data_key | String/None | None | It’s like an alias field name, It can change actual field name during serialization & deserialization. |
attribute | String/None | None | |
validate | None | ||
metadata | None |
PWeb DTO or Form default error messages
-
required : Missing data for required field.
-
null : Field may not be null.
-
validator_failed : Invalid value.