-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ provide
useOaModelAjv
to access ajv instance & addKeywords
- Loading branch information
Showing
6 changed files
with
45 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { KeywordDefinition } from 'ajv' | ||
|
||
export const keywords: KeywordDefinition[] = [{ | ||
keyword: 'range', // example from https://ajv.js.org/keywords.html#define-keyword-with-validate-function | ||
validate ([min, max], data, parentSchema, _dataCxt) { | ||
return data >= min && data <= max | ||
}, | ||
error: { | ||
message: ({ schema: [min, max], parentSchema }) => { | ||
return `Value must be between ${min} and ${max} (inclusive)` | ||
} | ||
}, | ||
metaSchema: { | ||
// schema to validate keyword value | ||
type: 'array', | ||
items: [{ type: 'number' }, { type: 'number' }], | ||
minItems: 2, | ||
additionalItems: false | ||
} | ||
}] |
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