Files
deno-valideno/validators/boolean.ts
2020-05-26 19:40:41 +02:00

17 lines
394 B
TypeScript

import { Validator, Args } from "../mod.ts";
export function isBoolean(): Validator {
return {
type: "isBoolean",
check: (value: any) => {
if (value === null || value === undefined) return;
if (value !== true && value !== false) {
return {};
}
},
message: (value: any, args?: Args) => {
return `This value has to be a boolean.`;
},
};
}