Attribute
Attribute
Bases: TemplateModel
A class that represents an attribute in a template model.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str: The name of the model. Name should be snake_case. From TemplateModel |
|
type |
DataType
|
DataType: The type of the attribute. |
default |
Any | None
|
Any|None: The default value of the attribute. Defaults to None. |
unique |
bool
|
bool: Whether or not the attribute is unique. Defaults to False. |
optional |
bool
|
bool: Whether or not the attribute is optional. Defaults to False. |
validation |
list[Callable[[Any], Any]]
|
list[Callable[[Any],Any]]: Not implemented. |
Source code in warp_fastapi\attributes.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__init__(name, type, default=None, unique=False, optional=False, validation_rules=[])
Initializes the attribute with the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
str: The name of the attribute. |
required |
type |
DataType
|
DataType: The type of the attribute. |
required |
default |
Any
|
Any: The default value of the attribute. Defaults to None. |
None
|
unique |
bool
|
bool: Whether or not the attribute is unique. Defaults to False. |
False
|
optional |
bool
|
bool: Whether or not the attribute is optional. Defaults to False. |
False
|
validation_rules |
list[Callable[[Any], Any]]
|
list[Callable[[Any],Any]]: Not implemented. |
[]
|
Source code in warp_fastapi\attributes.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
BoolAttribute(name, default=None, unique=False, optional=False)
Creates bool type attribute with DataType bool_type
Source code in warp_fastapi\attributes.py
102 103 104 105 | |
DateAttribute(name, default=None, unique=False, optional=False)
Creates date type attribute with DataType date_only_type
Source code in warp_fastapi\attributes.py
108 109 110 111 | |
DateTimeAttribute(name, default=None, unique=False, optional=False)
Creates datetime type attribute with DataType date_time_type
Source code in warp_fastapi\attributes.py
114 115 116 117 118 119 | |
DecimalAttribute(name, default=None, unique=False, optional=False)
Creates Decimal type attribute with DataType decimal_type
Source code in warp_fastapi\attributes.py
94 95 96 97 98 99 | |
DescriptionAttribute(default=None, unique=False, optional=False)
Creates string type attribute with DataType string_type. Default attribute name is description.
Source code in warp_fastapi\attributes.py
156 157 158 159 | |
EmailAttribute(name='email', default=None, unique=True, optional=False)
Creates email type attribute with DataType email_type. Default attribute name is email and it is set as unique
Source code in warp_fastapi\attributes.py
136 137 138 139 140 141 | |
FloatAttribute(name, default=None, unique=False, optional=False)
Creates float type attribute with DataType float_type
Source code in warp_fastapi\attributes.py
88 89 90 91 | |
IntAttribute(name, default=None, unique=False, optional=False)
Creates int type attribute with DataType int_type
Source code in warp_fastapi\attributes.py
82 83 84 85 | |
NameAttribute(default=None, unique=False, optional=False)
Creates string type attribute with DataType string_type. Default attribute name is name
Source code in warp_fastapi\attributes.py
144 145 146 147 | |
StringAttribute(name, default=None, unique=False, optional=False)
Creates string type attribute with DataType string_type
Source code in warp_fastapi\attributes.py
76 77 78 79 | |
TimeAttribute(name, default=None, unique=False, optional=False)
Creates time type attribute with DataType time_type
Source code in warp_fastapi\attributes.py
122 123 124 125 | |
TimeDeltaAttribute(name, default=None, unique=False, optional=False)
Creates timedelata type attribute with DataType timedelta_type
Source code in warp_fastapi\attributes.py
128 129 130 131 132 133 | |
UsernameAttribute()
Creates string type attribute with DataType string_type. Default attribute name is username. Attribute is always unique and it is not optional without default value.
Source code in warp_fastapi\attributes.py
150 151 152 153 | |