mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Modularize validation schemas (#3594). Integrated into release/v3.8.27 after rebase (reconciled the merged hiddenSidebarGroupLabels #3971 + intelligenceSyncRequestSchema into the new modules) + behavior verification (typecheck, 195 schema/settings/validation tests, build 556/556). Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
36 lines
900 B
TypeScript
36 lines
900 B
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
createProviderSchema,
|
|
createKeySchema,
|
|
loginSchema,
|
|
} from "../../src/shared/validation/schemas.ts";
|
|
|
|
test("modular schemas: createProviderSchema validates correctly", () => {
|
|
const valid = createProviderSchema.safeParse({
|
|
name: "openai",
|
|
provider: "openai",
|
|
apiKey: "sk-1234",
|
|
});
|
|
assert.equal(valid.success, true);
|
|
});
|
|
|
|
test("modular schemas: createKeySchema validates correctly", () => {
|
|
const valid = createKeySchema.safeParse({
|
|
name: "test-key",
|
|
});
|
|
assert.equal(valid.success, true);
|
|
});
|
|
|
|
test("modular schemas: loginSchema validates correctly", () => {
|
|
const valid = loginSchema.safeParse({
|
|
password: "securepassword",
|
|
});
|
|
assert.equal(valid.success, true);
|
|
|
|
const invalid = loginSchema.safeParse({
|
|
password: "",
|
|
});
|
|
assert.equal(invalid.success, false);
|
|
});
|