Skip to content

Commit 74e568c

Browse files
Rubin Bhandarivlapo
authored andcommitted
fix: add default message for isPort validator (#404)
1 parent 01aa7f1 commit 74e568c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/validation/ValidationTypes.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ValidationArguments} from "./ValidationArguments";
1+
import { ValidationArguments } from "./ValidationArguments";
22

33
/**
44
* Validation types.
@@ -102,15 +102,15 @@ export class ValidationTypes {
102102
* Checks if validation type is valid.
103103
*/
104104
static isValid(type: string) {
105-
return type !== "isValid" &&
105+
return type !== "isValid" &&
106106
type !== "getMessage" &&
107107
Object.keys(this).map(key => (this as any)[key]).indexOf(type) !== -1;
108108
}
109109

110110
/**
111111
* Gets default validation error message for the given validation type.
112112
*/
113-
static getMessage(type: string, isEach: boolean): string|((args: ValidationArguments) => string) {
113+
static getMessage(type: string, isEach: boolean): string | ((args: ValidationArguments) => string) {
114114
const eachPrefix = isEach ? "each value in " : "";
115115
switch (type) {
116116

@@ -132,6 +132,8 @@ export class ValidationTypes {
132132
return eachPrefix + "$property must be one of the following values: $constraint1";
133133
case this.IS_NOT_IN:
134134
return eachPrefix + "$property should not be one of the following values: $constraint1";
135+
case this.IS_PORT:
136+
return eachPrefix + "$property must be a port";
135137

136138
/* type checkers */
137139
case this.IS_BOOLEAN:

0 commit comments

Comments
 (0)