How to use the validator.isIP 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 wisnuc / appifi / src / fruitmix / lib / assertion.js View on Github external
const isCIDR = str => {

  if (typeof str !== 'string') return false

  let split = str.split('/')  
  if (split.length !== 2) return false
  if (!validator.isIP(split[0], 4)) return false
  
  let num = parseInt(split[1])
  return Number.isInteger(num) && num >= 0 && num <= 32 && ('' + num === split[1])
}
github ajainvivek / react-aztec / src / helpers / validation.js View on Github external
ip(value, version) {
    return validator.isIP(value, version);
  },
  ISBN(value, version) {
github wisnuc / appifi / src / system / sysconfig.js View on Github external
Array.isArray(ipAliasing) ? ipAliasing.filter(ent => 
    typeof ent.mac === 'string' && validator.isMACAddress(ent.mac) &&
    typeof ent.ipv4 === 'string' && validator.isIP(ent.ipv4, 4)) : undefined 
github TronLink / tronlink-extension / app / lib / utils.js View on Github external
if(!full.startsWith('https://'))
            return 'Full node must run through https protocol';

        if(!solidity.startsWith('https://'))
            return 'Solditity node must run through https protocol';

        if(event && !event.startsWith('https://'))
            return 'Event server must run through https protocol';

        if(!validator.isURL(full) && !validator.isIP(full))
            return 'Invalid full node provided';

        if(!validator.isURL(solidity) && !validator.isIP(solidity))
            return 'Invalid solidity node provided';

        if(!validator.isURL(event) && !validator.isIP(event))
            return 'Invalid event server provided';

        if(!this.isBoolean(mainnet))
            return 'Invalid network type provided';

        return false;
    },
github TronLink / tronlink-extension / app / lib / utils.js View on Github external
if(!this.isString(name) || !name.length || name.length > 256)
            return 'Invalid node name provided';

        if(!full.startsWith('https://'))
            return 'Full node must run through https protocol';

        if(!solidity.startsWith('https://'))
            return 'Solditity node must run through https protocol';

        if(event && !event.startsWith('https://'))
            return 'Event server must run through https protocol';

        if(!validator.isURL(full) && !validator.isIP(full))
            return 'Invalid full node provided';

        if(!validator.isURL(solidity) && !validator.isIP(solidity))
            return 'Invalid solidity node provided';

        if(!validator.isURL(event) && !validator.isIP(event))
            return 'Invalid event server provided';

        if(!this.isBoolean(mainnet))
            return 'Invalid network type provided';

        return false;
    },
github zaggino / z-schema / dist / ZSchema-browser.js View on Github external
"ipv4": function (ipv4) {
        if (typeof ipv4 !== "string") { return true; }
        return validator.isIP(ipv4, 4);
    },
    "ipv6": function (ipv6) {
github Encrypt-S / navtech / src / lib / SettingsValidator.js View on Github external
function validateIpAddress(value, validation, key) {
  if (!validator.isIP(value)) {
    SettingsValidator.errors.push('INVALID_IP_ADDRESS for ' + key + ', must be a valid IP Address')
    return true
  }
  return true
}
github flowgrammable / flowsim / backend / src / packet / ipv4.js View on Github external
exports.isIPaddress = function(address){
  return validator.isIP(address, 4);
};
github timbowhite / botbouncer / lib / schema.js View on Github external
Visitor.prototype.setIpv = function(ipv){
        if (lo.includes(ipvs, ipv)){
            this.ipv = ipv; 
            return;
        }
        if (validator.isIP(this.ip, 4)){
            this.ipv = 4;
            return;
        }
        if (validator.isIP(this.ip, 6)){
            this.ipv = 6;
            return;
        }

        throw Error('Failed to determine ipv from ip: ' + this.ip);
    };