How to use the isDecimal function from validator

Find comprehensive JavaScript validator.isDecimal code examples handpicked from public code repositorys.

163
164
165
166
167
168
169
170
171
172

validations.isDecimal = function isDecimal(paramName, customMessage) {
  return checkParam(
    paramName,
    customMessage || message(paramName, 'should be a decimal number'),
    validator.isDecimal
  );
}

validations.isInt = function isInt(paramName, options, customMessage) {
fork icon9
star icon0
watch icon1

71
72
73
74
75
76
77
78
79
80
81
82
83
84
// safe validators
const validAlphanumeric = url => validator.isAlphanumeric(url);


const validAlpha = url => validator.isAlpha(url);


const validDecimal = url => validator.isDecimal(url);


const validFloat = url => validator.isFloat(url);


const validInt = url => validator.isInt(url);
fork icon5
star icon63
watch icon0

33
34
35
36
37
38
39
40
41
42
        return callback(1, 'create_category_fail', 400, error, null);
    }
},
getOne: async (id, callback) => {
    try {
        if (!(Pieces.ValidTypeCheck(id, 'String', 0, 20) && Validator.isDecimal(id))) {
            return callback(1, 'invalid_category_id', 400, 'id of category is not a integer', null);
        }
        let where = { id: id };
        let resultCategory;
fork icon0
star icon0
watch icon0

+ 2 other calls in file

97
98
99
100
101
102
103
104
105
106
try {
    let update = {};
    let where = {};
    let resultProductDetail;

    if (!(Pieces.ValidTypeCheck(productDetailId, 'String', 0, 20) && Validator.isDecimal(productDetailId))) {
        return callback(1, 'Invalid_product_detail_id', 400, 'id of product detail is not a integer', null);
    }
    if (Pieces.ValidTypeCheck(data.price, 'String')&&Validator.isDecimal(data.price)) {
        update.price = data.price;
fork icon0
star icon0
watch icon0

147
148
149
150
151
152
153
154
155
156
    page = parseInt(query['page']);
    if (page === 0)
        page = 1;
}

if ((Pieces.ValidTypeCheck(query['perPage'], 'String') && Validator.isDecimal(query['perPage']))
    || (Pieces.ValidTypeCheck(query['perPage'], 'Number'))
) {
    perPage = parseInt(query['perPage']);
    if (perPage <= 0)
fork icon0
star icon0
watch icon0

+ 6 other calls in file

8
9
10
11
12
13
14
15
16
17
18
const GroupProduct = require('../models/GroupProduct.model');


module.exports = {
    getOptionByGroupProduct: async (groupProductId, callback) => {
        try {
            if (!(Pieces.ValidTypeCheck(groupProductId, 'String', 0, 20) && Validator.isDecimal(groupProductId))) {
                return callback(1, 'invalid_group_product_id', 400, 'id of group product id is not a integer', null);
            }
            let where = { groupProductId: groupProductId };
            let resultOption;
fork icon0
star icon0
watch icon0