Guest User

Untitled

a guest
Dec 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. 'fieldData.FROM_TIME': function(keyToGetData){
  2. return validator(function(value, options, model) {
  3. let fromTime = value;
  4. let toTime = model.get(keyToGetData);
  5. if(fromTime){
  6. let fromHours = fromTime.hours;
  7. let fromMins = fromTime.minutes;
  8.  
  9. // make validation only if toTime is there
  10. if(toTime){
  11. let toHours = toTime.hours;
  12. let toMins = toTime.minutes;
  13. if(fromHours > toHours || ( fromHours===toHours && fromMins > toMins) ){
  14. return 'From time must be earlier than To time.';
  15. }
  16. }
  17. return true;
  18. }
  19. return 'This field can not be blank';
  20. });
  21. },
  22.  
  23. 'fieldData.TO_TIME': function(keyToGetData){
  24. return validator(function(value, options, model) {
  25. let fromTime = model.get(keyToGetData);
  26. let toTime = value;
  27.  
  28. if(toTime){
  29. let toHours = toTime.hours;
  30. let toMins = toTime.minutes;
  31.  
  32. // make validation only if fromTime is there
  33. if(fromTime){
  34. let fromHours = fromTime.hours;
  35. let fromMins = fromTime.minutes;
  36.  
  37. if(fromHours > toHours || (fromHours===toHours && fromMins >= toMins) ){
  38. return 'To time must be later than From time.';
  39. }
  40. }
  41. return true;
  42. }
  43. return 'This field can not be blank';
  44. });
  45. }
Add Comment
Please, Sign In to add comment