Advertisement
MatthijsFontys

backup form validation function int

Jun 1st, 2020
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Adds an error if the value is not a number
  3.  * @param {String} customError custom error message, overrides default message
  4.  */
  5. export function isPositiveInt(customError){
  6.     return (input) => {
  7.         if(! Number.isInteger(input)){
  8.             addToErrors(input, `${input} is not a valid Integer`, customError)
  9.         }
  10.         else if(input < 0){
  11.             addToErrors(input, `${input} is not a positive number`, customError);
  12.         }
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement