Error Response Format - RingCentral-Pro-Services/psi-validator.js GitHub Wiki

About

In general, we want to be as verbose as possible. For any individual constraint (like password length), we want to specifically see if it's been violated.

With that in mind, when checking a provided element, if any constraint gets violated, instead of immediately failing and not checking other restraints, we should check them all and add all errors to an error response array. This will let the developer and user know exactly what they missed.

In an effort to make the life of the user and developer even easier, we should respond errors with the element that was supplied to us. This should make it simpler for debugging. Allows the dev to see the exact value that they passed into the validator.

See the below error response for a bad email address

{
  originalElement: 'john.celoria2ringcentral.someBadTld',
  errors: [
    'Emails require a valid top level domain',
    'Email format not valid. Should be {something}@{something}.{top level domain}'
  ]
}