class RssModel {
  constructor(payload = {}) {
    if (!this.schema) {
      throw new Error('please implement this.schema');
    }

    Object.assign(this, this.schema().cast(payload, { abortEarly: false, stripUnknown: true }));
  }

  isValid() {
    if (!this.schema) {
      throw new Error('please implement this.schema');
    }

    return this.schema().isValidSync(this);
  }

  validate() {
    if (!this.schema) {
      throw new Error('please implement this.schema');
    }

    return this.schema().validateSync(this, { abortEarly: false });
  }
}

module.exports = RssModel;
