UNPKG

fortify-schema

Version:

A modern TypeScript validation library designed around familiar interface syntax and powerful conditional validation. Experience schema validation that feels natural to TypeScript developers while unlocking advanced runtime validation capabilities.

83 lines (77 loc) 2.17 kB
"gl.ts" content "// ==================================================================== // TEST ORIGINAL FAILING CASE // ==================================================================== import { Interface } from "../schema/mode/interfaces/Interface"; const schema = Interface({ id: "number", name: "string", email: "email", status: "active|inactive", permisions: "when status=active *? (del | read | write)[] : string[]?", role: "user|admin", access: "when role=admin *? =granted : =denied", }); const result = schema.safeParse({ id: 1, name: "John Doe", email: "john@example.com", status: "active", role: "admin", access: "granted", permisions: ["read", "writes"], }); if (result.success) { console.log("✅ Result:", result.data); } else { console.log("❌ Errors:", result.errors); } " bun src\core\private\gl.ts PS F:\Projects\NEHONIX\fortifyjs\src\core\schema> bun src\core\private\gl.ts Failed to parse conditional expression: when status=active *? (del | read | write)[] : string[]? [ { type: "SYNTAX_ERROR", message: "Parse error: Expected literal value, got LPAREN", position: 22, line: 1, column: 23, suggestion: "Check conditional syntax", context: { nearbyTokens: [ { type: "IDENTIFIER", value: "active", position: 12, line: 1, column: 13, }, { type: "CONDITIONAL_THEN", value: "*?", position: 19, line: 1, column: 20, }, { type: "LPAREN", value: "(", position: 22, line: 1, column: 23, }, { type: "IDENTIFIER", value: "del", position: 23, line: 1, column: 24, }, { type: "PIPE", value: "|", position: 27, line: 1, column: 28, } ], expectedTokens: [], }, } ] Errors: [ "permisions: Element 1: Expected one of: when status=active *? (del, read, write)[] : string, got writes" ]