SHARE
TWEET

backup form validation function int

MatthijsFontys Jun 1st, 2020 618 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top