Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcusstenbeck/9c687040ede4c4c2481e1bf66a29bf16 to your computer and use it in GitHub Desktop.
Save marcusstenbeck/9c687040ede4c4c2481e1bf66a29bf16 to your computer and use it in GitHub Desktop.
const max50 = str => str.length <= 50;
module.exports = function addShow({ title, time, host, location }) {
if (!title || !max50(title)) {
throw new Error(`title can't be longer than 50 characters`);
}
if (!(time instanceof Date)) {
throw new Error(`time must be a date object`);
}
if (!host || !max50(host)) {
throw new Error(`host can't be longer than 50 characters`);
}
if (!location || !max50(location)) {
throw new Error(`location can't be longer than 50 characters`);
}
// Data good ... Save a ShowAdded event
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment