@middy/validator 7.1.0 → 7.1.2
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 -1
- package/index.d.ts +11 -5
- package/package.json +4 -3
- package/transpile.d.ts +12 -2
- package/transpile.js +1 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>Middy validator middleware</h1>
|
|
2
|
+
<h1>Middy `validator` middleware</h1>
|
|
3
3
|
<img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/docs/img/middy-logo.svg"/>
|
|
4
4
|
<p><strong>Validator middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
|
|
5
5
|
<p>
|
package/index.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import type middy from "@middy/core";
|
|
4
|
+
import type { ErrorObject } from "ajv";
|
|
4
5
|
|
|
5
|
-
interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export interface ValidateFunction<T = unknown> {
|
|
7
|
+
(data: unknown): data is T;
|
|
8
|
+
errors?: ErrorObject[] | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Options {
|
|
12
|
+
eventSchema?: ValidateFunction;
|
|
13
|
+
contextSchema?: ValidateFunction;
|
|
14
|
+
responseSchema?: ValidateFunction;
|
|
9
15
|
defaultLanguage?: string;
|
|
10
|
-
languages?:
|
|
16
|
+
languages?: Record<string, (errors: ErrorObject[] | undefined) => void>;
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
declare function validator(options?: Options): middy.MiddlewareObj;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/validator",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.2",
|
|
4
4
|
"description": "Validator middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"url": "https://github.com/sponsors/willfarrell"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@middy/util": "7.1.
|
|
78
|
+
"@middy/util": "7.1.2",
|
|
79
79
|
"ajv": "8.18.0",
|
|
80
80
|
"ajv-errors": "3.0.0",
|
|
81
81
|
"ajv-formats": "3.0.1",
|
|
@@ -84,7 +84,8 @@
|
|
|
84
84
|
"ajv-keywords": "5.1.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@middy/core": "7.1.
|
|
87
|
+
"@middy/core": "7.1.2",
|
|
88
|
+
"@types/aws-lambda": "^8.0.0",
|
|
88
89
|
"@types/http-errors": "^2.0.0",
|
|
89
90
|
"ajv-bsontype": "^1.0.7",
|
|
90
91
|
"ajv-cmd": "^0.8.0"
|
package/transpile.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
// Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import type { Ajv, Options as AjvOptions } from "ajv";
|
|
3
|
+
import type { Ajv, ErrorObject, Options as AjvOptions } from "ajv";
|
|
4
|
+
|
|
5
|
+
export type LocalizeFunction = (errors: ErrorObject[] | undefined) => void;
|
|
4
6
|
|
|
5
7
|
export function transpileSchema(
|
|
6
8
|
schema: object,
|
|
7
9
|
ajvOptions?: Partial<AjvOptions>,
|
|
8
10
|
): Ajv;
|
|
9
11
|
|
|
10
|
-
export function transpileLocale(
|
|
12
|
+
export function transpileLocale(
|
|
13
|
+
src: string,
|
|
14
|
+
options?: object | any,
|
|
15
|
+
): LocalizeFunction;
|
|
16
|
+
|
|
17
|
+
export function transpileFTL(
|
|
18
|
+
src: string,
|
|
19
|
+
options?: object | any,
|
|
20
|
+
): LocalizeFunction;
|
package/transpile.js
CHANGED
|
@@ -29,11 +29,9 @@ import ajvFormats from "ajv-formats";
|
|
|
29
29
|
import { transpile } from "ajv-ftl-i18n";
|
|
30
30
|
import ajvKeywords from "ajv-keywords";
|
|
31
31
|
|
|
32
|
-
// import transpileFTL from 'ajv-cmd/ftl'
|
|
33
32
|
export const transpileFTL = transpile;
|
|
34
33
|
|
|
35
|
-
//
|
|
36
|
-
// import compileSchema from 'ajv-cmd/compile'
|
|
34
|
+
// Inlined from `ajv-cmd/compile` to avoid extra dependency
|
|
37
35
|
|
|
38
36
|
const instance = (options = {}) => {
|
|
39
37
|
Object.assign(options, { keywords: [] });
|