Skip to content

2.4.0

Compare
Choose a tag to compare
@lukejagodzinski lukejagodzinski released this 21 Feb 13:41
· 70 commits to v2 since this release
  • Union type
import { Class, Union } from 'meteor/jagi:astronomy';

const StringOrNumber = Union.create({
  name: 'StringOrNumber',
  types: [String, Number],
  cast(value) {
    if (typeof value !== 'string') {
      return String(value);
    }
    return value;
  }
});

const Item = Class.create({
  name: 'Item',
  fields: {
    strOrNum: StringOrNumber
  }
});