{"version":3,"file":"boolean-validator.mjs","names":[],"sources":["../../../../../../../@warlock.js/seal/src/validators/boolean-validator.ts"],"sourcesContent":["import {\n  acceptedIfPresentRule,\n  acceptedIfRequiredRule,\n  acceptedIfRule,\n  acceptedRule,\n  acceptedUnlessRule,\n  acceptedWithoutRule,\n  declinedIfPresentRule,\n  declinedIfRequiredRule,\n  declinedIfRule,\n  declinedRule,\n  declinedUnlessRule,\n  declinedWithoutRule,\n} from \"../rules/scalar\";\nimport { booleanRule } from \"../rules\";\nimport { PrimitiveValidator } from \"./primitive-validator\";\nimport { applyNullable } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\n\n/**\n * Boolean validator class\n *\n * Extends PrimitiveValidator — inherits enum/in/oneOf/allowsOnly/forbids/notIn.\n * Defines accepted/declined directly as real methods (not ScalarValidator field copies)\n * so they survive cloning correctly.\n */\nexport class BooleanValidator extends PrimitiveValidator {\n  public constructor(errorMessage?: string) {\n    super();\n    this.addMutableRule(booleanRule, errorMessage);\n  }\n\n  /**\n   * Check if value is a boolean type\n   */\n  public matchesType(value: any): boolean {\n    return typeof value === \"boolean\";\n  }\n\n  // ==================== Accepted ====================\n\n  /** Value must be accepted (true, \"yes\", 1, \"on\", etc.) */\n  public accepted(errorMessage?: string) {\n    return this.addRule(acceptedRule, errorMessage);\n  }\n\n  /** Value must be accepted if another field equals a value */\n  public acceptedIf(field: string, value: any, errorMessage?: string) {\n    return this.addRule(acceptedIfRule, errorMessage, { field, value });\n  }\n\n  /** Value must be accepted unless another field equals a value */\n  public acceptedUnless(field: string, value: any, errorMessage?: string) {\n    return this.addRule(acceptedUnlessRule, errorMessage, { field, value });\n  }\n\n  /** Value must be accepted if another field is required */\n  public acceptedIfRequired(field: string, errorMessage?: string) {\n    return this.addRule(acceptedIfRequiredRule, errorMessage, { field });\n  }\n\n  /** Value must be accepted if another field is present */\n  public acceptedIfPresent(field: string, errorMessage?: string) {\n    return this.addRule(acceptedIfPresentRule, errorMessage, { field });\n  }\n\n  /** Value must be accepted if another field is missing */\n  public acceptedWithout(field: string, errorMessage?: string) {\n    return this.addRule(acceptedWithoutRule, errorMessage, { field });\n  }\n\n  // ==================== Declined ====================\n\n  /** Value must be declined (false, \"no\", 0, \"off\", etc.) */\n  public declined(errorMessage?: string) {\n    return this.addRule(declinedRule, errorMessage);\n  }\n\n  /** Value must be declined if another field equals a value */\n  public declinedIf(field: string, value: any, errorMessage?: string) {\n    return this.addRule(declinedIfRule, errorMessage, { field, value });\n  }\n\n  /** Value must be declined unless another field equals a value */\n  public declinedUnless(field: string, value: any, errorMessage?: string) {\n    return this.addRule(declinedUnlessRule, errorMessage, { field, value });\n  }\n\n  /** Value must be declined if another field is required */\n  public declinedIfRequired(field: string, errorMessage?: string) {\n    return this.addRule(declinedIfRequiredRule, errorMessage, { field });\n  }\n\n  /** Value must be declined if another field is present */\n  public declinedIfPresent(field: string, errorMessage?: string) {\n    return this.addRule(declinedIfPresentRule, errorMessage, { field });\n  }\n\n  /** Value must be declined if another field is missing */\n  public declinedWithout(field: string, errorMessage?: string) {\n    return this.addRule(declinedWithoutRule, errorMessage, { field });\n  }\n\n  // ==================== Strict boolean checks ====================\n\n  /**\n   * Value must be strictly true (not \"yes\", \"on\", 1, etc.)\n   * @alias accepted - strict version\n   */\n  public mustBeTrue(errorMessage?: string) {\n    return this.equal(true, errorMessage);\n  }\n\n  /**\n   * Value must be strictly false (not \"no\", \"off\", 0, etc.)\n   * @alias declined - strict version\n   */\n  public mustBeFalse(errorMessage?: string) {\n    return this.equal(false, errorMessage);\n  }\n\n  /**\n   * @inheritdoc\n   *\n   * @note accepted/declined rules and all cross-field boolean rules\n   * are not representable in JSON Schema and are silently omitted.\n   *\n   * @example\n   * ```ts\n   * v.boolean().toJsonSchema(\"draft-2020-12\")\n   * // → { type: \"boolean\" }\n   *\n   * v.boolean().nullable().toJsonSchema(\"openapi-3.0\")\n   * // → { type: \"boolean\", nullable: true }\n   * ```\n   */\n  public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n    const schema: JsonSchemaResult = { type: \"boolean\" };\n    if (this.isNullable) applyNullable(schema, target);\n    return schema;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,IAAa,mBAAb,cAAsC,mBAAmB;CACvD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eAAe,aAAa,YAAY;CAC/C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,OAAO,UAAU;CAC1B;;CAKA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,QAAQ,cAAc,YAAY;CAChD;;CAGA,AAAO,WAAW,OAAe,OAAY,cAAuB;EAClE,OAAO,KAAK,QAAQ,gBAAgB,cAAc;GAAE;GAAO;EAAM,CAAC;CACpE;;CAGA,AAAO,eAAe,OAAe,OAAY,cAAuB;EACtE,OAAO,KAAK,QAAQ,oBAAoB,cAAc;GAAE;GAAO;EAAM,CAAC;CACxE;;CAGA,AAAO,mBAAmB,OAAe,cAAuB;EAC9D,OAAO,KAAK,QAAQ,wBAAwB,cAAc,EAAE,MAAM,CAAC;CACrE;;CAGA,AAAO,kBAAkB,OAAe,cAAuB;EAC7D,OAAO,KAAK,QAAQ,uBAAuB,cAAc,EAAE,MAAM,CAAC;CACpE;;CAGA,AAAO,gBAAgB,OAAe,cAAuB;EAC3D,OAAO,KAAK,QAAQ,qBAAqB,cAAc,EAAE,MAAM,CAAC;CAClE;;CAKA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,QAAQ,cAAc,YAAY;CAChD;;CAGA,AAAO,WAAW,OAAe,OAAY,cAAuB;EAClE,OAAO,KAAK,QAAQ,gBAAgB,cAAc;GAAE;GAAO;EAAM,CAAC;CACpE;;CAGA,AAAO,eAAe,OAAe,OAAY,cAAuB;EACtE,OAAO,KAAK,QAAQ,oBAAoB,cAAc;GAAE;GAAO;EAAM,CAAC;CACxE;;CAGA,AAAO,mBAAmB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