Skip to content

Commit

Permalink
Pass schema object to processCode function
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 25, 2020
1 parent b3ce7f3 commit 1188d19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -1169,7 +1169,7 @@ Defaults:
errorDataPath: 'object', // deprecated
messages: true,
sourceCode: false,
processCode: undefined, // function (str: string): string {}
processCode: undefined, // function (str: string, schema: object): string {}
cache: new Cache,
serialize: undefined
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ajv.d.ts
Expand Up @@ -196,7 +196,7 @@ declare namespace ajv {
errorDataPath?: string,
messages?: boolean;
sourceCode?: boolean;
processCode?: (code: string) => string;
processCode?: (code: string, schema: object) => string;
cache?: object;
logger?: CustomLogger | false;
nullable?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/compile/index.js
Expand Up @@ -113,7 +113,7 @@ function compile(schema, root, localRefs, baseId) {
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode)
+ sourceCode;

if (opts.processCode) sourceCode = opts.processCode(sourceCode);
if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
var validate;
try {
Expand Down

0 comments on commit 1188d19

Please sign in to comment.