- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
50 lines
1.7 KiB
JavaScript
50 lines
1.7 KiB
JavaScript
import { Disjoint } from "../shared/disjoint.js";
|
|
import { implementNode } from "../shared/implement.js";
|
|
import { $ark } from "../shared/registry.js";
|
|
import { ToJsonSchema } from "../shared/toJsonSchema.js";
|
|
import { BaseRange, createLengthRuleParser, createLengthSchemaNormalizer } from "./range.js";
|
|
const implementation = implementNode({
|
|
kind: "maxLength",
|
|
collapsibleKey: "rule",
|
|
hasAssociatedError: true,
|
|
keys: {
|
|
rule: {
|
|
parse: createLengthRuleParser("maxLength")
|
|
}
|
|
},
|
|
reduce: (inner, $) => inner.rule === 0 ? $.node("exactLength", inner) : undefined,
|
|
normalize: createLengthSchemaNormalizer("maxLength"),
|
|
defaults: {
|
|
description: node => `at most length ${node.rule}`,
|
|
actual: data => `${data.length}`
|
|
},
|
|
intersections: {
|
|
maxLength: (l, r) => (l.isStricterThan(r) ? l : r),
|
|
minLength: (max, min, ctx) => max.overlapsRange(min) ?
|
|
max.overlapIsUnit(min) ?
|
|
ctx.$.node("exactLength", { rule: max.rule })
|
|
: null
|
|
: Disjoint.init("range", max, min)
|
|
}
|
|
});
|
|
export class MaxLengthNode extends BaseRange {
|
|
impliedBasis = $ark.intrinsic.lengthBoundable.internal;
|
|
traverseAllows = data => data.length <= this.rule;
|
|
reduceJsonSchema(schema) {
|
|
switch (schema.type) {
|
|
case "string":
|
|
schema.maxLength = this.rule;
|
|
return schema;
|
|
case "array":
|
|
schema.maxItems = this.rule;
|
|
return schema;
|
|
default:
|
|
return ToJsonSchema.throwInternalOperandError("maxLength", schema);
|
|
}
|
|
}
|
|
}
|
|
export const MaxLength = {
|
|
implementation,
|
|
Node: MaxLengthNode
|
|
};
|