Μετάβαση στο περιεχόμενο

updatable

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

updatable<TSchema>(schema): TSchema

Defined in: packages/pipeline-zod/src/updatable.ts:51

Marks a command field as updatable: a change the command requests, which field-level authorization must check.

createCommand lists the marked fields of the top-level object as the class’s static updatableFields, the list of fields to pass to field-level authorization. A field without the mark is never in that list, so mark every field the handler writes.

The mark survives the checks and wrappers chained after it (.min(), .optional(), .nullable(), .default(), .transform()) and .partial() on the object. It is set on a copy, so a schema shared with other commands stays unmarked.

TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

TSchema

The field schema to mark.

TSchema

A marked copy of schema, with the same type.

export class UpdateRoleCommand extends createCommand(
z.object({
id: z.uuid(),
name: z.string().trim().apply(updatable).min(3),
}),
) {}
UpdateRoleCommand.updatableFields; // ['name']