Skip to content

Commit 04d9d28

Browse files
committed
Update Programmer Network AJV library version and add new features
1 parent 8f38b60 commit 04d9d28

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,50 @@
11
# Programmer Network AJV
22

3-
Isomorphic Library that contains Custom AJV Keywords, Formats and AJV Validation
4-
Schemas used in Programmer Network's Client and API.
3+
Programmer Network AJV is an isomorphic library that enriches AJV (Another JSON Schema Validator) with custom keywords, formats, and validation schemas. These enhancements are tailored for use in both client-side and server-side environments. The library is meticulously designed to support custom validation logic that spans from detecting profanity to validating secure strings, YouTube URLs, and text presence with specific length constraints. Fully implemented in TypeScript, it ensures type safety and integrates seamlessly into TypeScript projects.
4+
5+
## Features
6+
7+
- **Custom AJV Keywords**: Includes a range of custom keywords such as `getBadWords`, `has-text`, `secure-string`, and `is-youtube-url`, with more to be added.
8+
- **Isomorphic Design**: Can be utilized on both the client (browser) and server (Node.js), making it a versatile choice for full-stack development.
9+
- **Comprehensive Validation**: From profanity checks to URL validation and string security assessments, the library covers a wide array of validation needs.
10+
- **Fully Tested**: Rigorously tested to ensure reliability and performance.
11+
- **TypeScript Support**: Written in TypeScript, offering type safety and ease of integration into TypeScript projects.
12+
13+
## Installation
14+
15+
To install Programmer Network AJV, use npm or yarn:
16+
17+
```bash
18+
pnpm i install @programmer-network/ajv
19+
```
20+
21+
## Usage
22+
23+
After installation, you can import and use the custom keywords in your AJV instances. Here's an example of how to add and use a custom keyword:
24+
25+
```typescript
26+
import Ajv from "ajv";
27+
import keywords from "@programmer-network/ajv";
28+
29+
const ajv = new Ajv();
30+
31+
// "register" the keywords
32+
keywords.map((keyword: KeywordDefinition) => ajv.addKeyword(keyword));
33+
```
34+
35+
You can use the custom keywords like you generally would:
36+
37+
```typescript
38+
const validate = ajv.compile({ type: "string", "secure-string": true });
39+
const valid = validate("some data to validate !!!)02_____d");
40+
41+
if (!valid) {
42+
console.log(validate.errors);
43+
}
44+
```
45+
46+
Take a look at [Keywords](./src/Keywords/) for all the available keywords. If you want more details into how the keywords are implemented, take a look at the [tests](./src/Utils/) for each of the utility classes.
47+
48+
## Contributing
49+
50+
We welcome contributions! If you have a custom AJV keyword, format, or schema that could benefit others, please consider submitting a pull request.

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/ajv",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A JSON Schema Validator",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {
@@ -61,10 +61,5 @@
6161
"vite": "^5.1.4",
6262
"vite-plugin-dts": "^3.7.3",
6363
"vitest": "^1.3.1"
64-
},
65-
"dependencies": {
66-
"ajv": "^8.12.0",
67-
"ajv-errors": "^3.0.0",
68-
"ajv-formats": "^2.1.1"
6964
}
7065
}

0 commit comments

Comments
 (0)