负整数(不包含0)
验证 负整数。
语法
import { negativeIntegerReg } from 'warbler-js';const result = negativeIntegerReg(value);
参数
value(String) : 待验证字符串。
返回值
Boolean : 是否通过验证,true 通过验证, false 没有通过验证。
源码
const negativeIntegerReg = (value) => {const reg = /^-[1-9]\d*$/;return reg.test(value);};
例子
import { negativeIntegerReg } from 'warbler-js';const result1 = negativeIntegerReg('0')const result2 = negativeIntegerReg('-3')const result3 = negativeIntegerReg('4')const result4 = negativeIntegerReg('1.1')const result5 = negativeIntegerReg('一尾流莺')console.log(result1) // falseconsole.log(result2) // trueconsole.log(result3) // falseconsole.log(result4) // falseconsole.log(result5) // false
