UI for Zipcoin Blue

formats.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var createIpValidator = require('is-my-ip-valid')
  2. var reEmailWhitespace = /\s/
  3. var reHostnameFirstPass = /^[a-zA-Z0-9.-]+$/
  4. var reHostnamePart = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$/
  5. var rePhoneFirstPass = /^\+[0-9][0-9 ]{5,27}[0-9]$/
  6. var rePhoneDoubleSpace = / {2}/
  7. var rePhoneGlobalSpace = / /g
  8. exports['date-time'] = /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}[tT ]\d{2}:\d{2}:\d{2}(?:\.\d+|)([zZ]|[+-]\d{2}:\d{2})$/
  9. exports['date'] = /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}$/
  10. exports['time'] = /^\d{2}:\d{2}:\d{2}$/
  11. exports['email'] = function (input) { return (input.indexOf('@') !== -1) && (!reEmailWhitespace.test(input)) }
  12. exports['ip-address'] = exports['ipv4'] = createIpValidator({ version: 4 })
  13. exports['ipv6'] = createIpValidator({ version: 6 })
  14. exports['uri'] = /^[a-zA-Z][a-zA-Z0-9+-.]*:[^\s]*$/
  15. exports['color'] = /(#?([0-9A-Fa-f]{3,6})\b)|(aqua)|(black)|(blue)|(fuchsia)|(gray)|(green)|(lime)|(maroon)|(navy)|(olive)|(orange)|(purple)|(red)|(silver)|(teal)|(white)|(yellow)|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\))/
  16. exports['hostname'] = function (input) {
  17. if (!(reHostnameFirstPass.test(input))) return false
  18. var parts = input.split('.')
  19. for (var i = 0; i < parts.length; i++) {
  20. if (!(reHostnamePart.test(parts[i]))) return false
  21. }
  22. return true
  23. }
  24. exports['alpha'] = /^[a-zA-Z]+$/
  25. exports['alphanumeric'] = /^[a-zA-Z0-9]+$/
  26. exports['style'] = /\s*(.+?):\s*([^;]+);?/g
  27. exports['phone'] = function (input) {
  28. if (!(rePhoneFirstPass.test(input))) return false
  29. if (rePhoneDoubleSpace.test(input)) return false
  30. var digits = input.substring(1).replace(rePhoneGlobalSpace, '').length
  31. return (digits >= 7 && digits <= 15)
  32. }
  33. exports['utc-millisec'] = /^[0-9]{1,15}\.?[0-9]{0,15}$/