refactor: reintroduce validateThing method

This commit is contained in:
Rainer Killinger
2019-05-07 11:32:22 +02:00
parent f90e93c1f4
commit c4a403e807
2 changed files with 39 additions and 4 deletions

View File

@@ -182,6 +182,20 @@ export function isSchemaWithDefinitions(schema: JSONSchema): schema is SchemaWit
return typeof schema.definitions !== 'undefined';
}
// tslint:disable: completed-docs
/**
* Guard method for determining if an object (a thing) has a type property with a type of string
*
* @param thing An object (thing)
*/
export function isThingWithType(thing: unknown): thing is { type: string; } {
return typeof thing === 'object' &&
thing !== null &&
'type' in thing &&
typeof (thing as { type: string; }).type === 'string';
}
// tslint:enable: completed-docs
/**
* Get path that contains a tsconfig.json
*