-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smaller bundle - next bunch of migrations...
- Loading branch information
Christoph Linder
committed
Nov 13, 2018
1 parent
1320d29
commit 3907863
Showing
15 changed files
with
158 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {buildMessage, ValidateBy} from "./ValidateBy"; | ||
import {ValidationOptions} from "./ValidationOptions"; | ||
import validatorJsContains = require("validator/lib/contains"); | ||
|
||
/** | ||
* Checks if the string contains the seed. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function contains(value: string, seed: string): boolean { | ||
return typeof value === "string" && validatorJsContains(value, seed); | ||
} | ||
|
||
/** | ||
* Checks if the string contains the seed. | ||
*/ | ||
export function Contains(seed: string, validationOptions?: ValidationOptions) { | ||
return ValidateBy({ | ||
name: "contains", | ||
validate: (value, args) => contains(value, args.constraints[0]), | ||
constraints: [seed], | ||
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain a $constraint1 string", validationOptions), | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {buildMessage, ValidateBy} from "./ValidateBy"; | ||
import {ValidationOptions} from "./ValidationOptions"; | ||
import validatorJsIsBoolean = require("validator/lib/isBoolean"); | ||
|
||
/** | ||
* Checks if a string is a boolean. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isBooleanString(value: string): boolean { | ||
return typeof value === "string" && validatorJsIsBoolean(value); | ||
} | ||
|
||
/** | ||
* Checks if a string is a boolean. | ||
*/ | ||
export function IsBooleanString(validationOptions?: ValidationOptions) { | ||
return ValidateBy({ | ||
name: "isBooleanString", | ||
validate: (value) => isBooleanString(value), | ||
defaultMessage: buildMessage((eachPrefix) => eachPrefix + eachPrefix + "$property must be a boolean string", validationOptions) | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {ValidationOptions} from "./ValidationOptions"; | ||
import {buildMessage, ValidateBy} from "./ValidateBy"; | ||
import validatorJsIsNumeric = require("validator/lib/isNumeric"); | ||
|
||
/** | ||
* Checks if the string is numeric. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isNumberString(value: string, options?: ValidatorJS.IsNumericOptions): boolean { | ||
return typeof value === "string" && validatorJsIsNumeric(value, options); | ||
} | ||
|
||
/** | ||
* Checks if the string is a number. | ||
*/ | ||
export function IsNumberString(validationOptions?: ValidationOptions) { | ||
return ValidateBy({ | ||
name: "isNumberString", | ||
validate: (value) => isNumberString(value), | ||
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a number string", validationOptions) | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.