Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. var test1 = "test12345";
  2. var test2 = "1234";
  3. var test3 = "";
  4.  
  5. var constraints1 = {
  6. length: {
  7. is: 4
  8. }
  9. }
  10.  
  11. var constraints2 = {
  12. length: {
  13. minimum: 4
  14. }
  15. }
  16.  
  17. var constraints3 = {
  18. length: {
  19. maximum: 4
  20. }
  21. }
  22.  
  23. console.log('Testing for exact length');
  24. console.log(validate.single(test1, constraints1));
  25. console.log(validate.single(test2, constraints1));
  26. console.log(validate.single(test3, constraints1));
  27.  
  28. console.log('Testing for min length');
  29. console.log(validate.single(test1, constraints2));
  30. console.log(validate.single(test2, constraints2));
  31. console.log(validate.single(test3, constraints2));
  32.  
  33. console.log('Testing for max length');
  34. console.log(validate.single(test1, constraints3));
  35. console.log(validate.single(test2, constraints3));
  36. console.log(validate.single(test3, constraints3));
  37.  
  38. [Log] Testing for exact length
  39. [Log] ["is the wrong length (should be 4 characters)"]
  40. [Log] undefined
  41. [Log] undefined
  42. [Log] Testing for min length
  43. [Log] undefined
  44. [Log] undefined
  45. [Log] undefined
  46. [Log] Testing for max length
  47. [Log] ["is too long (maximum is 4 characters)"]
  48. [Log] undefined
  49. [Log] undefined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement