Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. Store = new SimpleSchema({
  2. name: {
  3. type: String,
  4. label: 'Store Name'
  5. },
  6. location: {
  7. type: String,
  8. label: 'Location'
  9. },
  10. products: {
  11. type: [Product],
  12. label: 'Products'
  13. },
  14. status: {
  15. type: String,
  16. label: 'Store Status',
  17. allowedValues: ['Active', 'Inactive', 'Closed'],
  18. defaultValue: 'Active'
  19. }
  20. });
  21.  
  22. Product = new SimpleSchema({
  23. name: {
  24. type: String,
  25. label: 'Product Name'
  26. },
  27. tag: {
  28. type: String,
  29. label: 'Tag',
  30. optional: true,
  31. custom: function () {
  32. // Tag must be required if store status is Active
  33. // Need to get store status
  34. const storeStatus = this.field('status');
  35. if (storeStatus === 'Active') {
  36. return 'required';
  37. }
  38. }
  39. },
  40. status: {
  41. type: String,
  42. label: 'Product Status',
  43. allowedValues: ['Active', 'Inactive'],
  44. defaultValue: 'Active'
  45. }
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement