motorhead.validator
Validator
Bases: BoundMethodWrapper[TOwner, [TInsertOrUpdate, ClauseOrMongoQuery | None], InsertUpdateConfig]
Validator method wrapper.
Validator methods receive an insert or update object, and execute some - potentially async - operations to make sure the inserted or updated data is valid.
Source code in motorhead/validator.py
validator(config='insert-update')
Service method decorator factory that converts the decorated method into a Validator
instance.
Example:
class SVC(Service):
@validator("update")
def check_something(self, data: InsertData | CreateData, query: ClauseOrMongoQuery | None) -> None:
raise ValueError("Always fail.")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
InsertUpdateConfig
|
Validatator config. |
'insert-update'
|