- 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
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
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: "minLength",
|
|
collapsibleKey: "rule",
|
|
hasAssociatedError: true,
|
|
keys: {
|
|
rule: {
|
|
parse: createLengthRuleParser("minLength")
|
|
}
|
|
},
|
|
reduce: inner => inner.rule === 0 ?
|
|
// a minimum length of zero is trivially satisfied
|
|
$ark.intrinsic.unknown
|
|
: undefined,
|
|
normalize: createLengthSchemaNormalizer("minLength"),
|
|
defaults: {
|
|
description: node => node.rule === 1 ? "non-empty" : `at least length ${node.rule}`,
|
|
// avoid default message like "must be non-empty (was 0)"
|
|
actual: data => (data.length === 0 ? "" : `${data.length}`)
|
|
},
|
|
intersections: {
|
|
minLength: (l, r) => (l.isStricterThan(r) ? l : r)
|
|
}
|
|
});
|
|
export class MinLengthNode extends BaseRange {
|
|
impliedBasis = $ark.intrinsic.lengthBoundable.internal;
|
|
traverseAllows = data => data.length >= this.rule;
|
|
reduceJsonSchema(schema) {
|
|
switch (schema.type) {
|
|
case "string":
|
|
schema.minLength = this.rule;
|
|
return schema;
|
|
case "array":
|
|
schema.minItems = this.rule;
|
|
return schema;
|
|
default:
|
|
return ToJsonSchema.throwInternalOperandError("minLength", schema);
|
|
}
|
|
}
|
|
}
|
|
export const MinLength = {
|
|
implementation,
|
|
Node: MinLengthNode
|
|
};
|