From d3ef69fe98c4abb41b0edf04b4faa871d159ee7a Mon Sep 17 00:00:00 2001 From: Harry Grumbar Date: Thu, 23 Nov 2017 15:33:11 +0000 Subject: [PATCH] fix: Remove commented-out import --- src/rules.ts | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/rules.ts b/src/rules.ts index 11a6d1c..ad00a09 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -1,50 +1,48 @@ -// import isEqual = require('lodash/isEqual') - -export type Rule = (val: any, req: T) => boolean; +export type Rule = (val: any, req: T) => boolean export interface DefaultRules { - required: Rule; - equals: Rule; - min: Rule; - max: Rule; + required: Rule + equals: Rule + min: Rule + max: Rule } export function required(val: any, req: boolean = true) { if (!req) { - return true; + return true } if (val === undefined || val === null) { - return false; + return false } - return String(val).replace(/\s/g, "").length > 0; + return String(val).replace(/\s/g, '').length > 0 } export function equals(val: any, compare: any) { - return val === compare; + return val === compare } export function min(val: any, req: number) { - return getSize(val) >= req; + return getSize(val) >= req } export function max(val: any, req: number) { - return getSize(val) <= req; + return getSize(val) <= req } -const rules: DefaultRules = { required, equals, min, max }; +const rules: DefaultRules = { required, equals, min, max } -export default rules; +export default rules function getSize(val: any) { if (val instanceof Array) { - return val.length; + return val.length } - if (typeof val === "number") { - return val; + if (typeof val === 'number') { + return val } - return val.length; + return val.length }