Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async validateSchema(config: BabelConfig, resource: string, result: IJSONResult): Promise {
const validationResult = validate(this.schema, config, result.getLocation);
const valid = validationResult.valid;
if (!valid) {
await this.engine.emitAsync('parse::error::babel-config::schema', {
error: new Error('Invalid Babel configuration'),
errors: validationResult.errors,
groupedErrors: validationResult.groupedErrors,
prettifiedErrors: validationResult.prettifiedErrors,
resource
});
}
return validationResult;
}
} catch (e) {
await this.engine.emitAsync(this.parseJSONErrorEventName, {
error: e,
resource
});
return;
}
/*
* Try to see if the content of the web app manifest file
* is a valid acording to the schema.
*/
const validationResult: SchemaValidationResult = validate(schema, result.data, result.getLocation);
if (!validationResult.valid) {
await this.engine.emitAsync(this.parseErrorSchemaEventName, {
error: new Error('Invalid manifest'),
errors: validationResult.errors,
groupedErrors: validationResult.groupedErrors,
prettifiedErrors: validationResult.prettifiedErrors,
resource
});
return;
}
/*
* If it is, return the parsed content among with
const validateHint = (schema: object, hintConfig: object): boolean => {
return schemaValidator(schema, hintConfig).valid;
};
private async validateSchema(config: TypeScriptConfig, resource: string, result: IJSONResult): Promise {
const validationResult = validate(this.schema, config, result.getLocation);
const valid = validationResult.valid;
if (!valid) {
await this.engine.emitAsync(`parse::error::typescript-config::schema`, {
error: new Error('Invalid TypeScript configuration'),
errors: validationResult.errors,
groupedErrors: validationResult.groupedErrors,
prettifiedErrors: validationResult.prettifiedErrors,
resource
});
}
return validationResult;
}
private validateSchema(config: IJsonSchemaForNpmPackageJsonFiles, resource: string, result: IJSONResult): SchemaValidationResult {
return validate(this.schema, config, result.getLocation);
}
public static validateConnectorConfig(config: Configuration) {
const connectorId = config.connector!.name;
debug(`Validating ${connectorId} connector`);
const Connector = loadResource(connectorId, ResourceType.connector) as IConnectorConstructor;
debug(`Connector schema:`);
debug(Connector.schema);
debug(`User configuration:`);
debug(config.connector!.options!);
return schemaValidator(Connector.schema, config.connector!.options!).valid;
}