MCPcopy Index your code
hub / github.com/codecombat/codecombat / validate

Method validate

app/models/User.js:507–524  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 }

Callers 11

User.spec.jsFile · 0.45
schemaValidateObjectTestFunction · 0.45
schemaValidateObjectTestFunction · 0.45
onSubmitPatchMethod · 0.45
submitPatchMethod · 0.45
saveMethod · 0.45
onSaveModelMethod · 0.45

Calls

no outgoing calls

Tested by 6

schemaValidateObjectTestFunction · 0.36
schemaValidateObjectTestFunction · 0.36