Skip to content

Commit 881cabd

Browse files
committed
refactor: lint and prettier and clean up IsNotBlank decorator
1 parent e735126 commit 881cabd

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/decorator/common/IsNotBlank.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
import { ValidationOptions } from '../ValidationOptions';
22
import { buildMessage, ValidateBy } from './ValidateBy';
33

4-
export const IS_NOT_BLANK = "isNotBlank";
4+
export const IS_NOT_BLANK = 'isNotBlank';
55

66
export function isNotBlank(value: unknown): boolean {
7-
return (
8-
!!value && typeof value === "string" && value.trim().length > 0
9-
);
7+
return !!value && typeof value === 'string' && value.trim().length > 0;
108
}
119

12-
export function IsNotBlank(
13-
validationOptions?: ValidationOptions,
14-
): PropertyDecorator {
10+
export function IsNotBlank(validationOptions?: ValidationOptions): PropertyDecorator {
1511
return ValidateBy(
1612
{
1713
name: IS_NOT_BLANK,
1814
validator: {
1915
validate: (value): boolean => isNotBlank(value),
20-
defaultMessage: buildMessage(
21-
(eachPrefix) => eachPrefix + "$property should not be blank",
22-
validationOptions,
23-
),
16+
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property should not be blank', validationOptions),
2417
},
2518
},
26-
validationOptions,
19+
validationOptions
2720
);
2821
}

test/functional/validation-functions-and-decorators.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ describe('IsNotBlank', () => {
485485
const message = 'someProperty should not be blank';
486486
return checkReturnedError(new MyClass(), invalidValues, validationType, message);
487487
});
488-
})
488+
});
489489

490490
describe('IsIn', () => {
491491
const constraint = ['foo', 'bar'] as const;

0 commit comments

Comments
 (0)