New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

multi-error

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-error

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

1.0.0
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 01 Apr 2016

Did you know?

Socket

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