Socket
Socket
Sign inDemoInstall

multi-error

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    multi-error

```js import MultiError from 'error-suite'


Version published
Weekly downloads
1
Maintainers
1
Install size
1.45 MB
Created
Weekly downloads
 

Readme

Source

Error Suite

npm i error-suite --save

MultiError

import MultiError from 'error-suite'

let multierror = new MultiError('Invalid Form.')
multierror.push('Invalid Name')
multierror.push('Invalid Email')
multierror.push('Invalid Phone Number')

console.log(multierror.errors) // [ [Error: Invalid Name], [Error: Invalid Email], [Error: Invalid Phone Number] ]
console.log(multierror.messages) // [ 'Invalid Name', 'Invalid Email', 'Invalid Phone Number' ]
console.log(multierror.errorsPresent) // true
console.log(multierror.shouldThrow) // true
if (multierror.shouldThrow) throw multierror // Error: Invalid Form. | Invalid Name, Invalid Email, Invalid Phone Number

LangError

const locales = {
  "en": {
    "login_errors": {
      "invalid_name": "Invalid Name: {name}!",
      'invalid_email': "Invalid email!",
    }
  },
  "de": {
    "login_errors": {
      "invalid_name": "Ungültiger Name: {name}!",
      "invalid_email": "Ungültiger email!",
    }
  },
  "es": {
    "login_errors": {
      "invalid_name": "Nombre no válido: {name}!",
      "invalid_email": "el correo electrónico es invalido",
    }
  }
}

let langerror = new LangError('invalid_name', { name: 'Thomas' }, {locales, nestedLocalesProp: 'login_errors'})
console.log(langerror.messages) // { en: 'Invalid Name: Thomas!', de: 'Ungültiger Name: Thomas!', es: 'Nombre no válido: Thomas!' })

FAQs

Last updated on 01 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc