All files / src/ruleHandlers matchers.js

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58              8x       8x                       8x                                                                    
import * as normal from './generalRules';
import * as number from './numberRules';
import * as string from './stringRules';
 
// If the rule expects an array as value, please put
// it here, so we can extract user defined error message
// without problem.
export const RuleWhichNeedsArray = ['inArray'];
 
// This is for rule which expect a boolean value,
// Will ignore the check if the value if false.
export const RuleWhichNeedsBoolean = [
  'isEmail',
  'isUrl',
  'isCreditCard',
  'isHexColor',
  'isDecimal',
  'isInt',
  'isNegative',
  'isPositive',
  'isIntOrDecimal'
];
 
const handlerMatcher = {
  /* String handlers */
  minLength: string.minLength,
  maxLength: string.maxLength,
  include: string.include,
  exclude: string.exclude,
  startWith: string.startWith,
  notStartWith: string.notStartWith,
  endWith: string.endWith,
  notEndWith: string.notEndWith,
 
  /* Number handlers */
  min: number.min,
  max: number.max,
  equal: number.equal,
  notEqual: number.notEqual,
  isPositive: number.isPositive,
  isNegative: number.isNegative,
  isInt: number.isInt,
  isDecimal: number.isDecimal,
  isIntOrDecimal: number.isIntOrDecimal,
 
  /* General handlers */
  inArray: normal.inArray,
  matchRegex: normal.matchRegex,
  isEmail: normal.isEmail,
  isUrl: normal.isUrl,
  isCreditCard: normal.isCreditCard,
  isHexColor: normal.isHexColor,
  notEmpty: normal.notEmpty,
  isIP: normal.isIP
};
 
export default handlerMatcher;