Skip to content

Commit

Permalink
fix(Container): Remove typings for validator keyword options due to u…
Browse files Browse the repository at this point in the history
…pstream typings issue
  • Loading branch information
bdfoster committed Nov 21, 2017
1 parent 6898f7f commit 61d9832
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface ContainerOptions {

export interface ContainerValidatorOptions extends ajv.Options {
keywords?: {
[key: string]: ajv.KeywordDefinition;
[key: string]: any;
};
}

Expand Down Expand Up @@ -123,10 +123,39 @@ export class Container extends AsyncEventEmitter {
};
}

if (!validatorKeywords.validate) {
validatorKeywords['validate'] = {
validate: (...args) => {
return args[0].apply(this, [args.slice(1, args.length)]);
}
};
}

for (const i in validatorKeywords) {
this.validator.addKeyword(i, validatorKeywords[i]);
}

// this.validator.addKeyword('mapper', {
// async: true,
// type: 'string',
// errors: true,
// validate: async (mapper, id, schema, path) => {
// return this.mappers[mapper].get(id).then((record) => {
// return (record.id === id);
// }).catch((error) => {
// if (error.name === 'NotFoundError') {
// throw new ValidationError({
// keyword: 'mapper',
// message: 'should reference an existing record in "' + mapper + '" collection',
// path: path
// });
// }
//
// throw error;
// });
// }
// });

if (options.mappers) {
for (const mapper in options.mappers) {
this.defineMapper(mapper, options.mappers[mapper]);
Expand Down

0 comments on commit 61d9832

Please sign in to comment.