diff --git a/README.md b/README.md index 8f00ff4..4c30647 100644 --- a/README.md +++ b/README.md @@ -539,6 +539,9 @@ These are available from the `@hyperjump/json-schema/experimental` export. Define a vocabulary that maps keyword name to keyword URIs defined using `addKeyword`. +* **hasVocabulary**: (dialectId: string) => boolean; + + Determine whether the vocabulary is supported. * **getKeywordId**: (keywordName: string, dialectId: string) => string Get the identifier for a keyword by its name. @@ -568,14 +571,17 @@ These are available from the `@hyperjump/json-schema/experimental` export. * **getDialectIds** This function retrieves the identifiers of all loaded JSON Schema dialects. -* **getDialect**: (dialectId: string) => Record; +* **getDialect**: (dialectId: string) => Record; + + This function retrieves all the keywords appropriate for a particular + dialect. +* **hasDialect**: (dialectId: string) => boolean; - This function retrieves all the keywords appropriate for a particular dialect. + Determine whether the dialect is supported. * **Validation**: Keyword A Keyword object that represents a "validate" operation. You would use this for compiling and evaluating sub-schemas when defining a custom keyword. - * **getSchema**: (uri: string, browser?: Browser) => Promise\ Get a schema by it's URI taking the local schema registry into account. diff --git a/lib/experimental.d.ts b/lib/experimental.d.ts index cd5a328..001ef55 100644 --- a/lib/experimental.d.ts +++ b/lib/experimental.d.ts @@ -60,6 +60,7 @@ export const getKeyword: (id: string) => Keyword; export const getKeywordByName: (keywordName: string, dialectId: string) => Keyword; export const getKeywordId: (keywordName: string, dialectId: string) => string; export const defineVocabulary: (id: string, keywords: Record) => void; +export const hasVocabulary: (vocabularyId: string) => boolean; export const loadDialect: (dialectId: string, dialect: Record, allowUnknownKeywords?: boolean) => void; export const unloadDialect: (dialectId: string) => void; export const hasDialect: (dialectId: string) => boolean; diff --git a/lib/experimental.js b/lib/experimental.js index bd59ded..7da17bd 100644 --- a/lib/experimental.js +++ b/lib/experimental.js @@ -1,7 +1,7 @@ export { compile, interpret, BASIC } from "./core.js"; export { addKeyword, getKeyword, getKeywordByName, getKeywordName, getKeywordId, - defineVocabulary, + defineVocabulary, hasVocabulary, loadDialect, unloadDialect, hasDialect, getDialectIds, getDialect } from "./keywords.js"; export { getSchema, toSchema, canonicalUri, buildSchemaDocument } from "./schema.js"; diff --git a/lib/keywords.js b/lib/keywords.js index 2027cd0..4dd5386 100644 --- a/lib/keywords.js +++ b/lib/keywords.js @@ -34,6 +34,8 @@ export const defineVocabulary = (id, keywords) => { _vocabularies[id] = keywords; }; +export const hasVocabulary = (vocabularyId) => vocabularyId in _vocabularies; + const _dialects = {}; const _allowUnknownKeywords = {};