Type Alias IValidationHook<Class>

IValidationHook: {
    [K in keyof Class]?: Class[K] extends (args: infer Argument) => unknown
        ? (input: unknown) => IValidation<Argument>
        : never
}

Type for custom validation function hooks.

IValidationHook defines the structure for custom validation functions that can be provided for each method in the application class. It creates a mapped type where each property corresponds to a method in the class, and the value is a validation function for that method's parameters.

The validation hook functions:

  • Receive the same argument type as the original method
  • Must return an IValidation result indicating success or failure
  • Replace the default type validation when specified
  • Enable custom business logic and runtime validation

Type constraints:

  • Only methods (functions) from the class can have validation hooks
  • Non-function properties are typed as never and cannot be validated
  • The validation function must match the method's parameter signature

Type Parameters

  • Class extends object

    The application class type containing methods to validate