Skip to content

Commit c7c1e5a

Browse files
committed
Reformatted some ternary operators.
1 parent 44e92c0 commit c7c1e5a

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

lib/src/rules/length.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ export function isLengthValid(
1616
length: number,
1717
validatorFn: (value: string, length: number) => boolean
1818
): boolean {
19-
return typeof value === 'string' ? validatorFn(value, length) : true;
19+
// Don't try to validate non string values
20+
return typeof value === 'string' ?
21+
validatorFn(value, length) :
22+
true;
2023
}

lib/src/rules/maxLength.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ export function maxLength(value: string, vm, customParams: LengthParams = DEFAUL
2020
}
2121

2222
function isStringLengthValid(value: string, length: number) {
23-
return isNaN(length) ? false : value.length <= length;
23+
return isNaN(length) ?
24+
false :
25+
value.length <= length;
2426
}

lib/src/rules/pattern.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ function parsePattern({ pattern }: PatternParams): RegExp {
2727
}
2828

2929
function getRegExp(pattern) {
30-
return pattern instanceof RegExp ? pattern : new RegExp(pattern);
30+
return pattern instanceof RegExp ?
31+
pattern :
32+
new RegExp(pattern);
3133
}

lib/src/rules/required.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ function isValidField(value, trim: boolean): boolean {
2121
}
2222

2323
function isNotFalsy(value) {
24-
return value !== null && value !== undefined && value !== false;
24+
return value !== null &&
25+
value !== undefined &&
26+
value !== false;
2527
}
2628

2729
function isStringValid(value: string, trim: boolean): boolean {
28-
return trim ? value.trim().length > 0 : value.length > 0;
30+
return trim ?
31+
value.trim().length > 0 :
32+
value.length > 0;
2933
}

lib/src/rules/spec/email.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('[email] validation rule tests =>', () => {
2020

2121
it('should return false if value is undefined', () => {
2222
// Arrange
23-
const value = null;
23+
const value = undefined;
2424
const vm = undefined;
2525
const customParams = undefined;
2626

0 commit comments

Comments
 (0)