From 721bb5e7f3dfefe16a6bb9503c0b90d89ac6d246 Mon Sep 17 00:00:00 2001 From: HaiWei Lian Date: Tue, 12 Nov 2024 22:25:15 +0800 Subject: [PATCH 1/5] docs: update changelog for 0.14.1 (#2542) --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad4085a40..46f65a8f55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ _This changelog follows the [keep a changelog][keep-a-changelog]_ format to maintain a human readable changelog. +### [0.14.1](https://github.com/typestack/class-validator/compare/v0.14.0...v0.14.1) (2024-01-12) + +#### Added + +- allow specifying options for `@IsBase64` decorator ([#1845](https://github.com/typestack/class-validator/issues/1845)) , closes [#1013](https://github.com/typestack/class-validator/issues/1013) +- use official type for version in `@IsUUID` decorator ([#1846](https://github.com/typestack/class-validator/issues/1846)) , closes [#1497](https://github.com/typestack/class-validator/issues/1497) +- update `@IsPhoneNumber` decorator to use max dataset ([#1857](https://github.com/typestack/class-validator/issues/1857)) + +#### Fixed + +- fail for non-array constraint in `@IsIn` decorator ([#1844](https://github.com/typestack/class-validator/issues/1844)) , closes [#1693](https://github.com/typestack/class-validator/issues/1693) +- allow number and boolean values in validation message "$value" tokens ([#1467](https://github.com/typestack/class-validator/issues/1467)) , closes [#921](https://github.com/typestack/class-validator/issues/921), [#1046](https://github.com/typestack/class-validator/issues/1046) +- read nullable option in `@IsNotEmptyObject` decorator correctly ([#1555](https://github.com/typestack/class-validator/issues/1555)) , closes [#1554](https://github.com/typestack/class-validator/issues/1554) + +#### Changed + +- update `libphonenumber-js` to `^1.10.53` from `^1.10.14` +- update various dev-dependencies + ### [0.14.0](https://github.com/typestack/class-validator/compare/v0.13.2...v0.14.0) (2022-12-09) ### Added From b07bb1640a50db858963828377ce2c577386b947 Mon Sep 17 00:00:00 2001 From: HaiWei Lian Date: Tue, 26 Nov 2024 20:42:50 +0800 Subject: [PATCH 2/5] ci: update codecov (#2556) --- .../workflows/continuous-integration-workflow.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 678661213c..0b87426ef9 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -27,10 +27,15 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm ci --ignore-scripts - run: npm run test:ci - - run: npm install codecov -g - if: ${{ matrix.node-version == 'current' }} - - run: codecov -f ./coverage/clover.xml -t ${{ secrets.CODECOV_TOKEN }} --commit=$GITHUB_SHA --branch=${GITHUB_REF##*/} - if: ${{ matrix.node-version == 'current' }} + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + if: ${{ matrix.node-version == 'current' && github.actor != 'dependabot[bot]' }} + with: + files: ./coverage/clover.xml + directory: ./coverage/lcov-report/ + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + fail_ci_if_error: true build: name: Build runs-on: ubuntu-latest From 0c87bebe8b290a2527b8390c4a4877d7412bc2d9 Mon Sep 17 00:00:00 2001 From: AliReza Seyfpour <39882738+aseyfpour@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:30:30 +0330 Subject: [PATCH 3/5] fix: pass IsBase64 options correctly (#2549) * fix: fill base64 options correctly pass the constraint to the isBase64 function add unit test IsBase64 options * refactor: pass options by name --------- Co-authored-by: Brage Sekse Aarset --- src/decorator/string/IsBase64.ts | 2 +- ...validation-functions-and-decorators.spec.ts | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/decorator/string/IsBase64.ts b/src/decorator/string/IsBase64.ts index 2c5cd3e5be..c59a97009b 100644 --- a/src/decorator/string/IsBase64.ts +++ b/src/decorator/string/IsBase64.ts @@ -26,7 +26,7 @@ export function IsBase64( name: IS_BASE64, constraints: [options], validator: { - validate: (value, args): boolean => isBase64(value), + validate: (value, args): boolean => isBase64(value, options), defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions), }, }, diff --git a/test/functional/validation-functions-and-decorators.spec.ts b/test/functional/validation-functions-and-decorators.spec.ts index 78ceddcd6d..9f938616c4 100644 --- a/test/functional/validation-functions-and-decorators.spec.ts +++ b/test/functional/validation-functions-and-decorators.spec.ts @@ -1658,17 +1658,27 @@ describe('IsBase64', () => { const validValues = ['aGVsbG8=']; const invalidValues = [null, undefined, 'hell*mynameisalex']; + const validBase64UrlValues = ['dGVzdA', 'dGV_zdA']; + const invalidBase64UrlValues = [null, undefined, 'dGVzdA=', 'MTIzNDU2Nzg5!!', 'SGVsbG8+V29ybGQ=']; + class MyClass { @IsBase64() someProperty: string; } - it('should not fail if validator.validate said that its valid', () => { - return checkValidValues(new MyClass(), validValues); + class MyClassWithConstraint { + @IsBase64({ urlSafe: true }) + someProperty: string; + } + + it('should not fail if validator.validate said that its valid', async () => { + await checkValidValues(new MyClass(), validValues); + await checkValidValues(new MyClassWithConstraint(), validBase64UrlValues); }); - it('should fail if validator.validate said that its invalid', () => { - return checkInvalidValues(new MyClass(), invalidValues); + it('should fail if validator.validate said that its invalid', async () => { + await checkInvalidValues(new MyClass(), invalidValues); + await checkInvalidValues(new MyClassWithConstraint(), invalidBase64UrlValues); }); it('should not fail if method in validator said that its valid', () => { From 3bff66f8eb83f250742fb61ed0fe9c5a0f996ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Ol=C3=A1h?= Date: Fri, 17 Jan 2025 14:01:51 +0100 Subject: [PATCH 4/5] build: disable Dependabot updates --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9d58c92e15..8dd39d1739 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,10 +6,10 @@ updates: interval: daily time: "10:00" timezone: Europe/Budapest - open-pull-requests-limit: 5 + open-pull-requests-limit: 0 versioning-strategy: increase commit-message: prefix: build include: scope ignore: - - dependency-name: "husky" \ No newline at end of file + - dependency-name: "husky" From 0ea279bf89f849e12651bfea141837fa28611416 Mon Sep 17 00:00:00 2001 From: Brage Sekse Aarset Date: Fri, 17 Jan 2025 15:29:15 +0200 Subject: [PATCH 5/5] fix: pass arguments correctly to isBase64 (#2574) * fix: update version in package-lock.json * fix: pass options to isBase64 correctly --- src/decorator/string/IsBase64.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/decorator/string/IsBase64.ts b/src/decorator/string/IsBase64.ts index c59a97009b..e7002e0e9a 100644 --- a/src/decorator/string/IsBase64.ts +++ b/src/decorator/string/IsBase64.ts @@ -26,7 +26,7 @@ export function IsBase64( name: IS_BASE64, constraints: [options], validator: { - validate: (value, args): boolean => isBase64(value, options), + validate: (value, args): boolean => isBase64(value, args?.constraints[0]), defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions), }, },