-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
170 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { type JsonValue } from "../types.ts"; | ||
import { type Type } from "./deps.ts"; | ||
|
||
// deno-lint-ignore no-explicit-any | ||
export type Method = (...args: any[]) => JsonValue | Promise<JsonValue>; | ||
export type Methods = { | ||
[method: string]: Method | { | ||
method: Method; | ||
// deno-lint-ignore no-explicit-any | ||
validation: Type<any>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from "./response.ts"; | ||
export * from "./method.ts"; | ||
export * from "./util.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { v } from "./util_deps.ts"; | ||
import { type JsonArray, type JsonObject, type JsonValue } from "../types.ts"; | ||
|
||
export type StringOrNull = string | null; | ||
export type NumberOrNull = number | null; | ||
|
||
// Validators for JsonPrimitive | ||
export const stringValidator = v.string(); | ||
export const numberValidator = v.number(); | ||
export const booleanValidator = v.boolean(); | ||
export const nullValidator = v.null(); | ||
|
||
// Validator for JsonPrimitive (union of all primitive types) | ||
export const primitiveValidator = v.union( | ||
stringValidator, | ||
numberValidator, | ||
booleanValidator, | ||
nullValidator, | ||
); | ||
|
||
// Recursive validators for JsonValue, JsonObject, and JsonArray | ||
export const valueValidator: v.Type<JsonValue> = v.lazy(() => | ||
v.union(primitiveValidator, objectValidator, arrayValidator) | ||
); | ||
export const objectValidator: v.Type<JsonObject> = v.lazy(() => | ||
v.record(valueValidator) | ||
); | ||
export const arrayValidator: v.Type<JsonArray> = v.lazy(() => | ||
v.array(valueValidator) | ||
); | ||
export const stringOrNullValidator: v.Type<StringOrNull> = v.union( | ||
stringValidator, | ||
nullValidator, | ||
); | ||
export const numberOrNullValidator: v.Type<NumberOrNull> = v.union( | ||
numberValidator, | ||
nullValidator, | ||
); | ||
|
||
// Combination Validators for Arrays and Objects with specific types | ||
export const stringArrayValidator = v.array(stringValidator); | ||
export const numberArrayValidator = v.array(numberValidator); | ||
export const booleanArrayValidator = v.array(booleanValidator); | ||
export const objectArrayValidator = v.array(objectValidator); | ||
export const stringOrNullArrayValidator = v.array(stringOrNullValidator); | ||
export const numberOrNullArrayValidator = v.array(numberOrNullValidator); | ||
|
||
export const stringObjectValidator = v.record(stringValidator); | ||
export const numberObjectValidator = v.record(numberValidator); | ||
export const booleanObjectValidator = v.record(booleanValidator); | ||
export const objectObjectValidator = v.record(objectValidator); | ||
export const stringOrNullObjectValidator = v.record(stringOrNullValidator); | ||
export const numberOrNullObjectValidator = v.record(numberOrNullValidator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as v from "https://deno.land/x/valita@v0.3.8/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.