How to use the validator.isNumeric function in validator

To help you get started, we’ve selected a few validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github doramart / DoraCMS / routes / index.js View on Github external
router.get('/:defaultUrl', function (req, res, next) {

    var defaultUrl = req.params.defaultUrl;
    var url = defaultUrl.split('___')[1];
    var indexUrl = defaultUrl.split('—')[0];
    if (indexUrl == 'page') { // 首页的分页
        var indexPage = defaultUrl.split('—')[1].split(".")[0];
        if(indexPage && validator.isNumeric(indexPage)){
            req.query.page = indexPage;
        }
        siteFunc.renderToTargetPageByType(req,res,'index');
    } else {
        var currentUrl = url;
        if (url) {
            if(url.indexOf("—") >= 0){
                currentUrl = url.split("—")[0];
                var catePageNo = (url.split("—")[1]).split(".")[0];
                if(catePageNo && validator.isNumeric(catePageNo)){
                    req.query.page = catePageNo;
                }
            }
            queryCatePage(req, res, currentUrl);
        }else{
            next();
github timeoff-management / application / lib / route / users / index.js View on Github external
end_date          = validator.trim(req.body['end_date']),
        adjustment        = validator.trim(req.body['adjustment']),
        password          = validator.trim(req.body['password_one']),
        password_confirm  = validator.trim(req.body['password_confirm']),
        admin             = validator.toBoolean(req.body['admin']),
        auto_approve      = validator.toBoolean(req.body['auto_approve']);

    // Validate provided parameters

    if (!validator.isEmail(email)) {
        req.session.flash_error(
            'New email of '+item_name+' should be valid email address'
        );
    }

    if (!validator.isNumeric(department_id)) {
        req.session.flash_error(
            'New department number of '+item_name+' should be a valid number'
        );
    }

    if (adjustment && ! validator.isFloat(adjustment) ) {
      req.session.flash_error(
        'New allowance adjustment of '+item_name+' should be a valid number'
      );
    } else if (adjustment && ! ( adjustment % 1 === 0 || Math.abs( adjustment % 1 ) === 0.5 )) {
      req.session.flash_error(
        'New allowance adjustment of '+item_name+' should be either whole integer number or with half'
      );
    }

    start_date = req.user.company.normalise_date( start_date );
github DefinitelyTyped / DefinitelyTyped / types / validator / validator-tests.ts View on Github external
result = validator.isMobilePhone('sample', 'tr-TR');
    result = validator.isMobilePhone('sample', 'uk-UA');
    result = validator.isMobilePhone('sample', 'vi-VN');
    result = validator.isMobilePhone('sample', 'zh-CN');
    result = validator.isMobilePhone('sample', 'zh-HK');
    result = validator.isMobilePhone('sample', 'zh-TW');
    result = validator.isMobilePhone('sample', 'any');
    result = validator.isMobilePhone('sample');
    result = validator.isMobilePhone('sample', ['pl-PL', 'pt-PT']);

    result = validator.isMongoId('sample');

    result = validator.isMultibyte('sample');

    result = validator.isNumeric('sample');
    result = validator.isNumeric('+358', { no_symbols: true });

    result = validator.isOctal('076543210');

    result = validator.isPort('sample');

    result = validator.isPostalCode('sample', 'AT');
    result = validator.isPostalCode('sample', 'AU');
    result = validator.isPostalCode('sample', 'BE');
    result = validator.isPostalCode('sample', 'BG');
    result = validator.isPostalCode('sample', 'CA');
    result = validator.isPostalCode('sample', 'CH');
    result = validator.isPostalCode('sample', 'CZ');
    result = validator.isPostalCode('sample', 'DE');
    result = validator.isPostalCode('sample', 'DK');
    result = validator.isPostalCode('sample', 'DZ');
    result = validator.isPostalCode('sample', 'ES');
github g0v / OneButton / client / App / index.jsx View on Github external
const isTimesValid = isNumeric('' + times)
    const isNameValid = isAscii(name) || isMultibyte(name)
    let YYYY, MM, DD, HH, mm
    ;[ YYYY, MM, DD ] = beginDate.split('-')
    const isBeginDateValid = isNumeric(YYYY) && isNumeric(MM) && isNumeric(DD)
    ;[ HH, mm ] = beginTime.split(':')
    const isBeginTimeValid = isNumeric(HH) && isNumeric(mm)
    ;[ YYYY, MM, DD ] = endDate.split('-')
    const isEndDateValid = isNumeric(YYYY) && isNumeric(MM) && isNumeric(DD)
    ;[ HH, mm ] = endTime.split(':')
    const isEndTimeValid = isNumeric(HH) && isNumeric(mm)
    ;[ YYYY, MM, DD ] = signupDate.split('-')
    const isSignupDateValid = isNumeric(YYYY) && isNumeric(MM) && isNumeric(DD)
    ;[ HH, mm ] = endTime.split(':')
    const isSignupTimeValid = isNumeric(HH) && isNumeric(mm)

    const isOk =
      isTimesValid && isNameValid &&
      isBeginDateValid && isBeginTimeValid &&
      isEndDateValid && isEndTimeValid &&
      isSignupDateValid && isSignupTimeValid

    return (
      <div id="{id}">
        <div>
          <h1>一鍵開大松</h1>
          <div id="{styles.panel}">
            <div id="{styles.panelLeft}">
              <form method="post">
                <div>
                  <label>第幾次</label></div></form></div></div></div></div>
github Caltech-IPAC / firefly / src / firefly / js / util / BrowserInfo.js View on Github external
function parseVersion(ua,key) {
    var idx= ua.indexOf(key);
    if (idx!==-1) idx+= key.length;
    var ver= ua.substring(idx);

    var found= false;
    var i;
    for(i=0; (i
github CronixMicroSystems / react-typescript-boilerplate / src / components / overall / validators.tsx View on Github external
export function ValidatorNumberOfPhysiciansAllowed (value) {
  return !validator.isNumeric(value)
}
github moderntribe / events-gutenberg / src / modules / elements / input / element.js View on Github external
return ! required;
		}

		let isValid = true;
		switch ( type ) {
			case 'tel':
				isValid = validator.isMobilePhone( value, 'any' );
				break;
			case 'email':
				isValid = validator.isEmail( value );
				break;
			case 'url':
				isValid = validator.isURL( value );
				break;
			case 'number':
				isValid = validator.isNumeric( value );
				break;
		}
		return isValid;
	}
github Colored-Coins / Colored-Coins-Block-Explorer / app / modules / validator.js View on Github external
var validateUtxoParts = function (utxoParts) {
  return validator.isHexInLength64(utxoParts[0]) && validator.isNumeric(utxoParts[1])
}
github freeCodeCamp / freeCodeCamp / api-server / server / boot / donate.js View on Github external
function validStripeForm(amount, duration, email) {
    return isEmail('' + email) &&
      isNumeric('' + amount) &&
      durationKeysConfig.includes(duration) &&
      duration === 'onetime'
      ? donationOneTimeConfig.includes(amount)
      : donationSubscriptionConfig.plans[duration];
  }
github dazejs / daze / packages / framework / src / validate / validators.ts View on Github external
export function isNumberString(value: any, options?: any) {
  return typeof value === 'string' && validator.isNumeric(value, options);
};