Files
klz-cables.com/.pnpm-store/v10/files/fb/c808ed5a41e18c33f409477d8d9d0b9e0e6a929a53f0d583b86d1f59d71ce43fb13457df818cb4e1eb8bb92113a5036fe9bf334e83bf680dff2909e6a91680
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

31 lines
857 B
Plaintext

import type {MacroKeywordDefinition} from "ajv"
import type {GetDefinition} from "./_types"
type RangeKwd = "range" | "exclusiveRange"
export default function getRangeDef(keyword: RangeKwd): GetDefinition<MacroKeywordDefinition> {
return () => ({
keyword,
type: "number",
schemaType: "array",
macro: function ([min, max]: [number, number]) {
validateRangeSchema(min, max)
return keyword === "range"
? {minimum: min, maximum: max}
: {exclusiveMinimum: min, exclusiveMaximum: max}
},
metaSchema: {
type: "array",
minItems: 2,
maxItems: 2,
items: {type: "number"},
},
})
function validateRangeSchema(min: number, max: number): void {
if (min > max || (keyword === "exclusiveRange" && min === max)) {
throw new Error("There are no numbers in range")
}
}
}