Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed getDialect #66

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ 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<string, string>;

This function retrieves all the keywords appropriate for a particular dialect.
* **Validation**: Keyword

A Keyword object that represents a "validate" operation. You would use this
Expand Down
1 change: 1 addition & 0 deletions lib/experimental.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const loadDialect: (dialectId: string, dialect: { [vocabularyId: string]:
export const unloadDialect: (dialectId: string) => void;
export const hasDialect: (dialectId: string) => boolean;
export const getDialectIds: () => string[];
export const getDialect: (dialectId: string) => Record<string, string>;

export type Keyword<A> = {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export { compile, interpret, BASIC } from "./core.js";
export {
addKeyword, getKeyword, getKeywordByName, getKeywordName, getKeywordId,
defineVocabulary,
loadDialect, unloadDialect, hasDialect, getDialectIds
loadDialect, unloadDialect, hasDialect, getDialectIds, getDialect
} from "./keywords.js";
export { getSchema, toSchema, canonicalUri, buildSchemaDocument } from "./schema.js";
export { default as Validation } from "./keywords/validation.js";
2 changes: 1 addition & 1 deletion lib/keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const getKeywordName = (dialectId, keywordId) => {
}
};

const getDialect = (dialectId) => {
export const getDialect = (dialectId) => {
if (!(dialectId in _dialects)) {
throw Error(`Encountered unknown dialect '${dialectId}'`);
}
Expand Down