{"version":3,"file":"literal.mjs","names":[],"sources":["../../../../../../../../@warlock.js/seal/src/rules/common/literal.ts"],"sourcesContent":["import { invalidRule, resolveTranslation, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Literal rule - value must be strictly equal to one of the literal values.\n *\n * Uses === (referential / strict equality), so distinguishes 1 from \"1\",\n * true from \"true\", etc. Mirrors `v.string().oneOf([...])` but at the\n * literal type level (TypeScript narrows to the union of literals).\n */\nexport const literalRule: SchemaRule<{ values: readonly (string | number | boolean)[] }> = {\n  name: \"literal\",\n  defaultErrorMessage: \"The :input must be one of the following values: :values\",\n  async validate(value: any, context) {\n    if (this.context.options.values.includes(value)) {\n      return VALID_RULE;\n    }\n\n    this.context.translationParams.values = this.context.options.values\n      .map(v =>\n        resolveTranslation({ key: String(v), rawValue: String(v), rule: this, context }),\n      )\n      .join(\", \");\n\n    return invalidRule(this, context);\n  },\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,cAA8E;CACzF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,QAAQ,QAAQ,OAAO,SAAS,KAAK,GAC5C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,SAAS,KAAK,QAAQ,QAAQ,OAC1D,KAAI,MACH,mBAAmB;GAAE,KAAK,OAAO,CAAC;GAAG,UAAU,OAAO,CAAC;GAAG,MAAM;GAAM;EAAQ,CAAC,CACjF,CAAC,CACA,KAAK,IAAI;EAEZ,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}