Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/validation/ValidationTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ValidationArguments} from "./ValidationArguments";
import { ValidationArguments } from "./ValidationArguments";

/**
* Validation types.
Expand Down Expand Up @@ -102,15 +102,15 @@ export class ValidationTypes {
* Checks if validation type is valid.
*/
static isValid(type: string) {
return type !== "isValid" &&
return type !== "isValid" &&
type !== "getMessage" &&
Object.keys(this).map(key => (this as any)[key]).indexOf(type) !== -1;
}

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

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

/* type checkers */
case this.IS_BOOLEAN:
Expand Down