Updates for 1.5.0
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/* tslint:disable */
|
||||
// generated by typescript-json-validator
|
||||
import {inspect} from 'util';
|
||||
import Ajv = require('ajv');
|
||||
import ShippedFileInfo from './ShippedFileInfo';
|
||||
export const ajv = new Ajv({"allErrors":true,"coerceTypes":false,"format":"fast","nullable":true,"unicode":true,"uniqueItems":true,"useDefaults":true});
|
||||
|
||||
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
|
||||
|
||||
export {ShippedFileInfo};
|
||||
export const ShippedFileInfoSchema = {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"defaultProperties": [
|
||||
],
|
||||
"properties": {
|
||||
"channel": {
|
||||
"type": "string"
|
||||
},
|
||||
"filename": {
|
||||
"type": "string"
|
||||
},
|
||||
"git_hash": {
|
||||
"type": "string"
|
||||
},
|
||||
"required_client": {
|
||||
"type": "string"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "number"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"channel",
|
||||
"filename",
|
||||
"git_hash",
|
||||
"required_client",
|
||||
"timestamp",
|
||||
"version"
|
||||
],
|
||||
"type": "object"
|
||||
};
|
||||
export type ValidateFunction<T> = ((data: unknown) => data is T) & Pick<Ajv.ValidateFunction, 'errors'>
|
||||
export const isShippedFileInfo = ajv.compile(ShippedFileInfoSchema) as ValidateFunction<ShippedFileInfo>;
|
||||
export default function validate(value: unknown): ShippedFileInfo {
|
||||
if (isShippedFileInfo(value)) {
|
||||
return value;
|
||||
} else {
|
||||
throw new Error(
|
||||
ajv.errorsText(isShippedFileInfo.errors!.filter((e: any) => e.keyword !== 'if'), {dataVar: 'ShippedFileInfo'}) +
|
||||
'\n\n' +
|
||||
inspect(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user