Skip to content
  • Projects
  • Groups
  • Snippets
  • Help

Письменов Дмитрий Иванович / yourroomads

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • yourroomads
  • resources
  • js
  • Utils
  • Errors.js
  • Jonathan Reinink's avatar
    Initial commit · 14192d0e
    Jonathan Reinink committed Mar 21, 2019
    14192d0e
Errors.js 407 Bytes
BlameHistoryPermalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
class Errors {
  constructor(errors = {}) {
    this.record(errors)
  }

  record(errors = {}) {
    this.errors = errors
  }

  all() {
    return this.errors
  }

  any() {
    return Object.keys(this.errors).length > 0
  }

  has(key) {
    return key in this.errors
  }

  first(field) {
    return this.get(field)[0]
  }

  get(field) {
    return this.errors[field] || []
  }
}

export default Errors