sanitizeModelInput
Function: sanitizeModelInput()
sanitizeModelInput<
T>(model,input,context?):T
Defined in: packages/core/src/services/domainservice.service.ts:54
Remove from client input the attributes a client cannot write, before it reaches a model (REST, gRPC, MCP and
GraphQL). The HTML sanitization of the texts is done before, by the operation input (context.getInput()) or by
sanitizeModelText:
__-prefixed (private) keys are removed at any depth;_-prefixed attributes are removed, unless the model lists them in its staticgetClientWritableAttributes(): by convention they are server-managed (_user,_roles,_groups,_creationDate...);- Behavior-typed attributes (Metadata.Relations.behaviors) are removed: behavior state can only be changed through the behavior's own actions;
- the attributes of the model's static
getProtectedAttributes(context)are removed, even when listed as writable: the caller context is passed, so a model can protect an attribute from some callers only (per-caller field write rules, see the Permissions documentation); - the attributes the model schemas mark
readOnly(@readOnlyon the property) are removed: they are server-managed.
Type Parameters
T
T = any
Parameters
model
ModelClass<any>
the model class
input
T
the client input
context?
the caller context, handed to getProtectedAttributes(context)
Returns
T
the sanitized input