58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
/* 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),
|
|
);
|
|
}
|
|
}
|