Files
klz-cables.com/.pnpm-store/v10/files/13/01c08eab213aabf410534f12aa967fc00dd60697ad798060209616da1d1d112d4b48df1c76807cb0b9712961f15f0ec2cc5bcd4acff09e00fdd1157be78b4a
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

51 lines
1.4 KiB
Plaintext

import type {AddedKeywordDefinition} from "../types"
const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"] as const
export type JSONType = (typeof _jsonTypes)[number]
const jsonTypes: Set<string> = new Set(_jsonTypes)
export function isJSONType(x: unknown): x is JSONType {
return typeof x == "string" && jsonTypes.has(x)
}
type ValidationTypes = {
[K in JSONType]: boolean | RuleGroup | undefined
}
export interface ValidationRules {
rules: RuleGroup[]
post: RuleGroup
all: {[Key in string]?: boolean | Rule} // rules that have to be validated
keywords: {[Key in string]?: boolean} // all known keywords (superset of "all")
types: ValidationTypes
}
export interface RuleGroup {
type?: JSONType
rules: Rule[]
}
// This interface wraps KeywordDefinition because definition can have multiple keywords
export interface Rule {
keyword: string
definition: AddedKeywordDefinition
}
export function getRules(): ValidationRules {
const groups: Record<"number" | "string" | "array" | "object", RuleGroup> = {
number: {type: "number", rules: []},
string: {type: "string", rules: []},
array: {type: "array", rules: []},
object: {type: "object", rules: []},
}
return {
types: {...groups, integer: true, boolean: true, null: true},
rules: [{rules: []}, groups.number, groups.string, groups.array, groups.object],
post: {rules: []},
all: {},
keywords: {},
}
}