Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validateModel(locale: string, validator: tv4.JsonSchema): void {
let model: JovoModelData;
try {
model = this.getModel(locale);
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
throw new Error(`Could not find model file for locale "${locale}"`);
}
throw error;
}
const valid = tv4.validate(model, validator);
if (valid === false) {
throw new ModelValidationError(tv4.error.message, locale, tv4.error.dataPath);
}
}