diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee70655..14a0ae0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,4 +24,4 @@ jobs: run: yarn test --ci --coverage --maxWorkers=2 - name: Build - run: yarn build + run: yarn build \ No newline at end of file diff --git a/src/index.test.ts b/src/index.test.ts index c945c51..31259c0 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -43,6 +43,26 @@ describe('betterAjvErrors', () => { }; }); + describe('combined schemas', () => { + it('should handle type errors', () => { + data = { + str: 123, + }; + const combinedSchema = {type: 'boolean'}; + const validateCombined = ajv.addSchema(combinedSchema).compile(schema); + validateCombined(data); + const betterErrors = betterAjvErrors({ data, schema, errors: validateCombined.errors }); + expect(betterErrors).toEqual([ + { + context: { + errorType: 'type', + }, + message: "'str' property type must be string", + path: '{base}.str', + }, + ]); + }); + }); describe('additionalProperties', () => { it('should handle additionalProperties=false', () => { data = { diff --git a/yarn.lock b/yarn.lock index f72eee8..b255119 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7996,4 +7996,4 @@ yargs@^15.3.1: yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== \ No newline at end of file