allowed null and undefined
This commit is contained in:
@@ -3,6 +3,7 @@ import { Validator, Args } from "../mod.ts";
|
||||
export const isNumber: Validator = {
|
||||
type: "isNumber",
|
||||
check: (value: any) => {
|
||||
if (value === null || value === undefined) return;
|
||||
if (!Number.isFinite(value)) {
|
||||
return {};
|
||||
}
|
||||
@@ -15,6 +16,7 @@ export const isNumber: Validator = {
|
||||
export const isInteger: Validator = {
|
||||
type: "isInteger",
|
||||
check: (value: any) => {
|
||||
if (value === null || value === undefined) return;
|
||||
if (!Number.isInteger(value)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user