Skip to content

Commit

Permalink
Inverse Assert for Compiler and Value Check Alignment (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Mar 27, 2023
1 parent ff2a63c commit e9f63d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/runtime/compiler/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export function Ok<T extends TSchema>(schema: T, data: unknown, references: any[
export function Fail<T extends TSchema>(schema: T, data: unknown, references: any[] = []) {
const C = TypeCompiler.Compile(schema, references)
const result = C.Check(data)
if (result !== Value.Check(schema, references, data)) {
throw Error('Compiler and Value Check disparity')
}
if (result === false) {
const errors = [...Value.Errors(schema, references, data)]
if (errors.length === 0) throw Error('expected at least 1 error')
Expand Down

0 comments on commit e9f63d8

Please sign in to comment.