Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
braaar authored Jan 17, 2025
2 parents a2156a1 + 0ea279b commit 87000a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
- dependency-name: "husky"
2 changes: 1 addition & 1 deletion src/decorator/string/IsBase64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, args?.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions),
},
},
Expand Down
18 changes: 14 additions & 4 deletions test/functional/validation-functions-and-decorators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 87000a7

Please sign in to comment.