1
0
Fork 0
js-yaml-schema/src/schema.ts

30 lines
645 B
TypeScript
Raw Normal View History

import { DEFAULT_SCHEMA } from 'js-yaml';
2019-11-13 14:01:51 +00:00
import { envType } from './type/Env';
import { createInclude, IncludeOptions } from './type/Include';
2019-11-13 14:01:51 +00:00
import { regexpType } from './type/Regexp';
import { streamType } from './type/Stream';
export interface SchemaOptions {
include: IncludeOptions;
}
/**
* Safe schema with additional library types added.
*
* @public
*/
export function createSchema(options: SchemaOptions) {
const includeType = createInclude(options.include);
const schema = DEFAULT_SCHEMA.extend([
envType,
includeType,
regexpType,
streamType,
]);
options.include.schema = schema;
return schema;
}