Kaizen
Browse modulesRulesrules/sharedTypes

Type Alias: AgeCheckConfig

type AgeCheckConfig = ZodUnion<readonly [ZodObject<{
  condition_type: ZodLiteral<"AGE_CHECK">;
  evaluation_date_field: ZodOptional<ZodString>;
  field: ZodString;
  max_age: ZodOptional<ZodNumber>;
  min_age: ZodNumber;
}, $strip>, ZodObject<{
  condition_type: ZodLiteral<"AGE_CHECK">;
  evaluation_date_field: ZodOptional<ZodString>;
  field: ZodString;
  max_age: ZodNumber;
  min_age: ZodOptional<ZodNumber>;
}, $strip>]>;

Defined in: shared/rules/types/conditions.ts:146

Resolve field as an ISO date of birth and check that the age in whole years at evaluation time falls within the min_age / max_age bounds (both inclusive). At least one of min_age or max_age must be provided — the union makes unbounded configs a parse-time error and narrows the TS type so consumers know at least one bound is set.

The evaluation ("as-of") date defaults to engine-now. For "age at booking time" / "age as of the session date" semantics — where the relevant age is anchored to a context value rather than the current moment — set evaluation_date_field to a dot-path resolving to an ISO date (e.g. booking.startsAt). This mirrors the override on RelativeDateCheckConfig: the first resolved value that parses as a valid ISO date wins, and if the path resolves to no valid ISO date the handler falls back to engine-now. Without the field, behavior is unchanged. Example: a "must be 6 by Sept 1" gate evaluated in June against a session that starts in September passes a child who turns 6 in August.