Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Store = new SimpleSchema({
- name: {
- type: String,
- label: 'Store Name'
- },
- location: {
- type: String,
- label: 'Location'
- },
- products: {
- type: [Product],
- label: 'Products'
- },
- status: {
- type: String,
- label: 'Store Status',
- allowedValues: ['Active', 'Inactive', 'Closed'],
- defaultValue: 'Active'
- }
- });
- Product = new SimpleSchema({
- name: {
- type: String,
- label: 'Product Name'
- },
- tag: {
- type: String,
- label: 'Tag',
- optional: true,
- custom: function () {
- // Tag must be required if store status is Active
- // Need to get store status
- const storeStatus = this.field('status');
- if (storeStatus === 'Active') {
- return 'required';
- }
- }
- },
- status: {
- type: String,
- label: 'Product Status',
- allowedValues: ['Active', 'Inactive'],
- defaultValue: 'Active'
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement