()
| 505 | } |
| 506 | |
| 507 | validate () { |
| 508 | const errors = super.validate() |
| 509 | if (errors && this._revertAttributes) { |
| 510 | // Do not return errors if they were all present when last marked to revert. |
| 511 | // This is so that if a user has an invalid property, that does not prevent |
| 512 | // them from editing their settings. |
| 513 | const definedAttributes = _.pick(this._revertAttributes, v => v !== undefined) |
| 514 | const oldResult = tv4.validateMultiple(definedAttributes, this.constructor.schema || {}) |
| 515 | const mapper = error => [error.code.toString(), error.dataPath, error.schemaPath].join(':') |
| 516 | const originalErrors = _.map(oldResult.errors, mapper) |
| 517 | const currentErrors = _.map(errors, mapper) |
| 518 | const newErrors = _.difference(currentErrors, originalErrors) |
| 519 | if (_.size(newErrors) === 0) { |
| 520 | return |
| 521 | } |
| 522 | } |
| 523 | return errors |
| 524 | } |
| 525 | |
| 526 | hasSubscription () { |
| 527 | if (this.isStudent() || this.isTeacher()) { return false } |
no outgoing calls