-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve error handling definitionVersionDiscovery
- Loading branch information
1 parent
be27cde
commit db4b2d5
Showing
9 changed files
with
145 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { ValidateFunction, ValidationError } from './validators'; | ||
|
||
declare module './validatePDv1.js' { | ||
const validate: ValidateFunction & { errors?: ValidationError[] | null }; | ||
export default validate; | ||
} |
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,6 @@ | ||
import type { ValidateFunction, ValidationError } from './validators'; | ||
|
||
declare module './validatePDv2.js' { | ||
const validate: ValidateFunction & { errors?: ValidationError[] | null }; | ||
export default validate; | ||
} |
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,71 @@ | ||
export interface ValidateFunction { | ||
(data: unknown): boolean; | ||
errors?: ValidationError[]; | ||
} | ||
|
||
export type ValidationParentSchema = { | ||
type?: string | string[]; | ||
properties?: { | ||
[key: string]: { | ||
type?: string; | ||
enum?: string[]; | ||
items?: { | ||
type?: string; | ||
$ref?: string; | ||
}; | ||
properties?: Record<string, unknown>; | ||
required?: string[]; | ||
additionalProperties?: boolean; | ||
$ref?: string; | ||
}; | ||
}; | ||
required?: string[]; | ||
additionalProperties?: boolean; | ||
items?: { | ||
type?: string; | ||
$ref?: string; | ||
}; | ||
}; | ||
|
||
export type ValidationData = { | ||
id?: string; | ||
name?: string; | ||
purpose?: string; | ||
constraints?: { | ||
limit_disclosure?: string; | ||
fields?: Array<{ | ||
path?: string[]; | ||
purpose?: string; | ||
filter?: { | ||
type?: string; | ||
pattern?: string; | ||
}; | ||
}>; | ||
}; | ||
schema?: Array<{ | ||
uri?: string; | ||
}>; | ||
[key: string]: unknown; | ||
}; | ||
|
||
export type ValidationError = { | ||
instancePath: string; | ||
schemaPath: string; | ||
keyword: string; | ||
params: { | ||
type?: string | string[]; | ||
limit?: number; | ||
comparison?: string; | ||
missingProperty?: string; | ||
additionalProperty?: string; | ||
propertyName?: string; | ||
i?: number; | ||
j?: number; | ||
allowedValues?: string[] | readonly string[]; | ||
passingSchemas?: number | number[]; | ||
}; | ||
message: string; | ||
schema: boolean | ValidationParentSchema; | ||
parentSchema: ValidationParentSchema; | ||
data: ValidationData; | ||
}; |
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