Skip to content

Function: integer() ​

ts
function integer(value, options?): ValidationResult;

Integer string validation / 整数字符串校验

Parameters ​

ParameterType
valuestring
options{ unsigned?: boolean; }
options.unsigned?boolean

Returns ​

ValidationResult

Example ​

ts
integer('-42') // => { isValid: true, message: undefined }
integer('3.14') // => { isValid: false, message: 'Value must be an integer / 必须为整数' }
integer('42', { unsigned: true }) // => { isValid: true, message: undefined }
integer('-1', { unsigned: true }) // => { isValid: false, message: 'Value must be an integer / 必须为整数' }

Since ​

1.0.0

Released under the MIT License.