@middy/validator 2.4.3 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -31
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ NOTES:
|
|
|
62
62
|
- At least one of `inputSchema` or `outputSchema` is required.
|
|
63
63
|
- **Important** Compiling schemas on the fly will cause a 50-100ms performance hit during cold start for simple JSON Schemas. Precompiling is highly recommended.
|
|
64
64
|
- Default ajv plugins used: `ajv-i18n`, `ajv-formats`, `ajv-formats-draft2019`
|
|
65
|
+
- If you'd like to have the error details as part of the response, it will need to be handled separately. You can access them from `request.error.details`, the original response can be found at `request.error.response`.
|
|
65
66
|
|
|
66
67
|
## Sample usage
|
|
67
68
|
|
|
@@ -133,38 +134,7 @@ handler({}, {}, (err, response) => {
|
|
|
133
134
|
})
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
Example for plugins applied with `ajv-bsontype`:
|
|
137
137
|
|
|
138
|
-
```javascript
|
|
139
|
-
import middy from '@middy/core'
|
|
140
|
-
import validator from '@middy/validator'
|
|
141
|
-
|
|
142
|
-
const handler = middy((event, context) => {
|
|
143
|
-
return {}
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
const schema = {
|
|
147
|
-
required: ["name", "gpa"],
|
|
148
|
-
properties: {
|
|
149
|
-
name: {
|
|
150
|
-
bsonType: "string"
|
|
151
|
-
},
|
|
152
|
-
gpa: {
|
|
153
|
-
bsonType: [ "double" ]
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
handler.use(validator({ inputSchema: schema, ajvPlugins: { bsontype: null } }))
|
|
159
|
-
|
|
160
|
-
// invokes the handler, note that property foo is string and should be integer
|
|
161
|
-
const event = {
|
|
162
|
-
body: JSON.stringify({ name: "Leo", gpa: "4" })
|
|
163
|
-
}
|
|
164
|
-
handler(event, {}, (err, response) => {
|
|
165
|
-
t.is(err.details[0].message,'should be double got 4')
|
|
166
|
-
})
|
|
167
|
-
```
|
|
168
138
|
|
|
169
139
|
## Middy documentation and examples
|
|
170
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/validator",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "Validator middleware for the middy framework",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"engines": {
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/middyjs/middy#readme",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@middy/util": "^2.
|
|
49
|
-
"ajv": "8.6.
|
|
50
|
-
"ajv-formats": "2.1.
|
|
51
|
-
"ajv-formats-draft2019": "1.
|
|
52
|
-
"ajv-i18n": "4.
|
|
48
|
+
"@middy/util": "^2.5.3",
|
|
49
|
+
"ajv": "8.6.3",
|
|
50
|
+
"ajv-formats": "2.1.1",
|
|
51
|
+
"ajv-formats-draft2019": "1.6.1",
|
|
52
|
+
"ajv-i18n": "4.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@middy/core": "^2.
|
|
56
|
-
"@types/http-errors": "^1.8.
|
|
55
|
+
"@middy/core": "^2.5.3",
|
|
56
|
+
"@types/http-errors": "^1.8.1",
|
|
57
57
|
"ajv-bsontype": "^1.0.7",
|
|
58
58
|
"http-errors": "^1.8.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "690884d43b9cd632aeca9a5eba1612160b987cd4"
|
|
61
61
|
}
|