Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 031f830

Browse files
committed
Edits for nodejs getting started article
1 parent 162fc30 commit 031f830

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pages/posts/get-started-with-json-schema-in-node-js.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The first step in putting together request validation for your Node.js applicati
2222

2323
Perhaps you've tried to build your own custom validation before, but it starts to feel messy and difficult to maintain. You want to put some reliable validation in place and move on to building exciting new features in your application. Why is adding in validation *such* a headache?!
2424

25-
In this article we're going to learn how the JSON Schema specification can help us create flexible validation rules. We'll write a schema which describes the format we expect data to be in, then we'll write some JavaScript that uses the Ajv validator library to validate our data against it.
25+
In this article, we're going to learn how the JSON Schema specification can help us create flexible validation rules. We'll write a schema which describes the format we expect data to be in, then we'll write some JavaScript that uses the Ajv validator library to validate our data against it.
2626

2727
Let's get started!
2828

@@ -42,7 +42,7 @@ Let's get hands-on and see what validating data with JSON Schema and Ajv looks l
4242
4343
## Creating a schema and validating data
4444

45-
First we need to run the command `npm install ajv` to install the Ajv library.
45+
First, we need to run the command `npm install ajv` to install the Ajv library.
4646

4747
Then we can jump straight into defining a JSON schema. It describes the structure and types we expect:
4848

@@ -148,7 +148,7 @@ If we `console.log` the `iceCreamSchema` object, we can see the JSON schema we'v
148148
}
149149
```
150150

151-
You'll notice this generated schema is almost identical to the `iceCreamSchema` we previously wrote "by hand". We can replace our hand crafted schema with this generated schema and the validation will behave in the same way as it did before.
151+
You'll notice this generated schema is almost identical to the `iceCreamSchema` we previously wrote "by hand". We can replace our handcrafted schema with this generated schema and the validation will behave in the same way as it did before.
152152

153153
If we're writing our applications in TypeScript, the [TypeBox](https://www.npmjs.com/package/@sinclair/typebox) library is a great alternative to `fluent-json-schema`.
154154

@@ -166,7 +166,7 @@ We can use Ajv as a standalone library or we can integrate it with the framework
166166

167167
When we combine JSON Schema and Ajv, we have a flexible solution for implementing validation in our Node.js applications:
168168

169-
- **Learn once, use everywhere.** The JSON Schema specification is cross-platform, and there are [validation libraries](https://json-schema.org/implementations.html) available for every popular programming language. We're not locked in to a library, framework or language. Once we've learnt the fundamentals of JSON Schema, we can use it everywhere.
169+
- **Learn once, use everywhere.** The JSON Schema specification is cross-platform, and there are [validation libraries](https://json-schema.org/implementations.html) available for every popular programming language. We're not locked into a library, framework or language. Once we've learnt the fundamentals of JSON Schema, we can use it everywhere.
170170
- **Portability.** Because JSON Schema is cross-platform, even if we decide to rewrite our applications in another framework or language, we can take our schemas with us.
171171
- **Speed**. Under the hood, Ajv compiles our JSON schemas into JavaScript code. This improves the performance of repeated validation of data against a schema. For example, schemas can be compiled by Ajv when our Node.js application starts. HTTP request data which the application receives can then be validated against the pre-compiled schemas.
172172
- **Active and supportive community**. There's an active community of folks on Slack who are happy to help out (the [JSON Schema website](https://json-schema.org/) has a link you can use to join).

0 commit comments

Comments
 (0)