a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627
  1. var assert = require('assert')
  2. var safeRegex = require('safe-regex')
  3. var validator = require('./')
  4. var invalid4 = require('./fixtures/invalid-ipv4-addresses')
  5. var invalid6 = require('./fixtures/invalid-ipv6-addresses')
  6. var valid4 = require('./fixtures/valid-ipv4-addresses')
  7. var valid6 = require('./fixtures/valid-ipv6-addresses')
  8. var validate = validator()
  9. var validate4 = validator({ version: 4 })
  10. var validate6 = validator({ version: 6 })
  11. var i
  12. for (i = 0; i < validator.__all_regexes__.length; i++) assert.ok(safeRegex(validator.__all_regexes__[i]), validator.__all_regexes__[i] + ' should be safe regex')
  13. for (i = 0; i < invalid4.length; i++) assert.strictEqual(validate4(invalid4[i]), false, invalid4[i] + ' should be invalid IPv4')
  14. for (i = 0; i < invalid6.length; i++) assert.strictEqual(validate6(invalid6[i]), false, invalid6[i] + ' should be invalid IPv6')
  15. for (i = 0; i < valid4.length; i++) assert.strictEqual(validate(valid4[i]), true, valid4[i] + ' should be valid IP')
  16. for (i = 0; i < valid4.length; i++) assert.strictEqual(validate4(valid4[i]), true, valid4[i] + ' should be valid IPv4')
  17. for (i = 0; i < valid6.length; i++) assert.strictEqual(validate(valid6[i]), true, valid6[i] + ' should be valid IP')
  18. for (i = 0; i < valid6.length; i++) assert.strictEqual(validate6(valid6[i]), true, valid6[i] + ' should be valid IPv6')