https://github.com/codibly/api-validation
https://github.com/codibly/api-validation
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/codibly/api-validation
- Owner: codibly
- License: mit
- Created: 2019-10-15T12:56:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:45:25.000Z (over 3 years ago)
- Last Synced: 2025-03-29T07:05:39.759Z (over 1 year ago)
- Language: TypeScript
- Size: 608 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.config.js
- License: LICENSE
Awesome Lists containing this project
README
# @codibly/api-validation
[](https://github.com/semantic-release/semantic-release)
[](https://github.com/prettier/prettier)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/facebook/jest)
[](https://www.npmjs.com/package/@codibly/api-validation)
[](https://www.npmjs.com/package/@codibly/api-validation)
[](https://www.npmjs.com/package/@codibly/api-validation)
[](https://www.npmjs.com/package/@codibly/api-validation)
## Installation
This package is available as an [npm package](https://www.npmjs.com/package/@codibly/api-validation).
```
npm install --save @codibly/api-validation
```
or
```
yarn add @codibly/api-validation
```
## Usage
The main gola of this library is to help is easy way handle api validation.
####Error Code
- VALIDATION_ERROR - validation form error code
####Check error code
To check if error has valid error code we use function `isError`
```
function isError(ErrorCode, Response | undefined): error is Error {}
```
####Get form errors
To get validation form errors we have to functions which reducer array of errors to simple object where key is a filed name and value is a string or object.
```
- ValidationErrorMapper.toFormError(error: Error): FormError
- ValidationErrorMapper.toFormErrorsWithSheetCells(error: Error, sheetField: string[]): FormError
```
## License
MIT