96jd-error-handler-utils
TypeScript icon, indicating that this package has built-in type declarations

18.0.1 • Public • Published

96jd-error-handler-utils

Installation

NPM

npm install 96jd-error-handler-utils

YARN

yarn add 96jd-error-handler-utils

Getting started

import {
	fieldCanNotBeEmpty,
	fieldMustBeAtLeastLength,
	fieldMustBeAtMaxLength,
	fieldMustBeBetweenLengths,
	fieldMustMatchDigitsLength,
	formHasErrors,
	getErrorMessageByHttpStatus
} from "96jd-error-handler-utils";
import _ from "lodash";

console.log(fieldCanNotBeEmpty("First Name"));
console.log(fieldMustMatchDigitsLength("Person Number", 11));
console.log(fieldMustBeAtLeastLength("Description", 50));
console.log(fieldMustBeAtMaxLength("Title", 50));
console.log(fieldMustBeBetweenLengths("Phone number", 8, 20));

console.log(getErrorMessageByHttpStatus(400));
console.log(getErrorMessageByHttpStatus(401, "en"));
console.log(getErrorMessageByHttpStatus(403, "no"));

const errors = {
	personNumber: "Error 1",
	firstName: "Error 2",
	lastName: "Error 3",
	phoneNumber: "Error 4",
	address: "Error 5",
	password: "Error 6",
	confirmPassword: "Error 7"
};

formHasErrors(errors) ? console.log(errors) : {};

Package Sidebar

Install

npm i 96jd-error-handler-utils

Weekly Downloads

0

Version

18.0.1

License

ISC

Unpacked Size

2.75 MB

Total Files

16

Last publish

Collaborators

  • 96jd