-
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.
Merge pull request #176 from Sphereon-Opensource/feature/VDX-339_erro…
…r-types feature/VDX-339_error-types
- Loading branch information
Showing
9 changed files
with
127 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,53 @@ | ||
import { PresentationDefinitionV1, PresentationDefinitionV2 } from '@sphereon/pex-models'; | ||
|
||
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 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: PresentationDefinitionV1 | PresentationDefinitionV2; | ||
}; |
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