Skip to content

IgnoreCallback

@tsed/schema

Usage ​

typescript
import { IgnoreCallback } from "@tsed/schema";

See /packages/specs/schema/src/domain/IgnoreCallback.ts.

Overview ​

ts
interface IgnoreCallback {
    (value: boolean, ctx: JsonHookContext): boolean;
}

Description ​

Callback function to determine whether a property should be ignored during serialization.

This callback is invoked during schema generation to conditionally ignore properties based on the current context and the default ignore value.

Usage ​

typescript
const ignoreCallback: IgnoreCallback = (value, ctx) => {
  // Ignore properties when specific groups are active
  if (ctx.groups?.includes('admin')) {
    return false; // Don't ignore for admin group
  }
  return value; // Use default ignore value
};

​

ts
(value: boolean, ctx: JsonHookContext): boolean;

Released under the MIT License.