Skip to content

Commit 64c39c2

Browse files
committed
docs: output code to stdout
1 parent 2c4f125 commit 64c39c2

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ For example, you can use `-c ajv-keywords` to add all keywords from [ajv-keyword
9797

9898
- `js` (default): JavaScript object
9999
- `json`: JSON with indentation and line-breaks
100-
- `line`: JSON without indentaion/line-breaks (for easy parsing)
100+
- `line`: JSON without indentation/line-breaks (for easy parsing)
101101
- `text`: human readable error messages with data paths
102102

103103
- `--changes=`: detect changes in data after validation.<br>
104-
Data can be modifyed with [Ajv options](#ajv-options) `--remove-additional`, `--use-defaults` and `--coerce-types`).<br>
104+
Data can be modified with [Ajv options](#ajv-options) `--remove-additional`, `--use-defaults` and `--coerce-types`).<br>
105105
The changes are reported in JSON-patch format ([RFC6902](https://tools.ietf.org/html/rfc6902)).<br>
106106
Possible values are `js` (default), `json` and `line` (see `--errors` option).
107107

@@ -114,28 +114,33 @@ It can be used to check that the schema is valid and to create a standalone modu
114114
```sh
115115
ajv compile -s schema
116116

117-
# compile to module (BETA)
117+
# compile to module file
118118
ajv compile -s schema -o validate.js
119+
120+
## compile to stdout, to allow code formatting (js-beautify has to be installed separately)
121+
ajv compile -s schema -o | js-beautify > validate.js
119122
```
120123

121124
#### Parameters
122125

123126
##### `-s` - file name(s) of JSON-schema(s)
124127

125-
Multiple schemas can be passed both by using this parameter mupltiple times and with [glob patterns](https://github.com/isaacs/node-glob#glob-primer).
128+
Multiple schemas can be passed both by using this parameter multiple times and with [glob patterns](https://github.com/isaacs/node-glob#glob-primer).
126129

127130
```sh
128131
ajv compile -s "test/schema*.json"
129132
```
130133

131-
##### `-o` - output file for compiled validation function module (BETA)
134+
##### `-o` - output file for compiled validation function module
132135

133136
Only a single schema can be compiled with this option.
134137

135138
```sh
136139
ajv compile -s "schema.json" -o "validate_schema.js"
137140
```
138141

142+
`-o` without parameter should be used to output code to stdout to pass it to some code formatter.
143+
139144
This command also supports parameters `-r`, `-m` and `-c` as in [validate](#validate-data) command.
140145

141146
### Migrate schemas
@@ -155,7 +160,7 @@ ajv migrate -s schema -o migrated_schema.json
155160

156161
##### `-s` - file name(s) of JSON-schema(s)
157162

158-
Multiple schemas can be passed both by using this parameter mupltiple times and with [glob patterns](https://github.com/isaacs/node-glob#glob-primer).
163+
Multiple schemas can be passed both by using this parameter multiple times and with [glob patterns](https://github.com/isaacs/node-glob#glob-primer).
159164

160165
```sh
161166
ajv migrate -s "test/schema*.json"

0 commit comments

Comments
 (0)