This commit is contained in:
Sebastian Seedorf
2020-05-26 00:11:46 +02:00
commit cd6ed23d47
7 changed files with 197 additions and 0 deletions

13
validators/string.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Validator, Args } from "../mod.ts";
export const isString: Validator = {
type: "isString",
check: (value: any) => {
if (typeof value !== 'string' && !(value instanceof String)) {
return {};
}
},
message: (value: any, args?: Args) => {
return `The value '${value && value.toString()}' has to be a string.`
}
}