@innet/server 2.0.0-alpha.9 → 2.0.0-beta.10
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 +1771 -799
- package/handler/handler.d.ts +26 -18
- package/handler/handler.es6.js +17 -14
- package/handler/handler.js +16 -13
- package/hooks/index.d.ts +26 -20
- package/hooks/index.es6.js +26 -20
- package/hooks/index.js +26 -20
- package/hooks/useAction/useAction.es6.js +1 -1
- package/hooks/useAction/useAction.js +1 -1
- package/hooks/useApi/useApi.d.ts +1 -3
- package/hooks/useClientIp/useClientIp.d.ts +1 -1
- package/hooks/useEffect/index.d.ts +1 -0
- package/hooks/useEffect/index.es6.js +1 -0
- package/hooks/useEffect/index.js +9 -0
- package/hooks/useEffect/useEffect.d.ts +2 -0
- package/hooks/useEffect/useEffect.es6.js +8 -0
- package/hooks/useEffect/useEffect.js +12 -0
- package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
- package/hooks/useEndpoint/useEndpoint.es6.js +3 -1
- package/hooks/useEndpoint/useEndpoint.js +3 -1
- package/hooks/useHeaders/useHeaders.d.ts +0 -1
- package/hooks/useIsServerHttps/index.d.ts +1 -0
- package/hooks/useIsServerHttps/index.es6.js +1 -0
- package/hooks/useIsServerHttps/index.js +10 -0
- package/hooks/useIsServerHttps/useIsServerHttps.d.ts +3 -0
- package/hooks/useIsServerHttps/useIsServerHttps.es6.js +14 -0
- package/hooks/useIsServerHttps/useIsServerHttps.js +19 -0
- package/hooks/useNewSchema/useNewSchema.es6.js +2 -2
- package/hooks/useNewSchema/useNewSchema.js +2 -2
- package/hooks/useObjectSchemaContext/index.d.ts +1 -0
- package/hooks/useObjectSchemaContext/index.es6.js +1 -0
- package/hooks/useObjectSchemaContext/index.js +10 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +3 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js +14 -0
- package/hooks/useObjectSchemaContext/useObjectSchemaContext.js +19 -0
- package/hooks/useRequest/index.es6.js +1 -1
- package/hooks/useRequest/index.js +0 -1
- package/hooks/useRequest/useRequest.d.ts +1 -5
- package/hooks/useRequest/useRequest.es6.js +4 -4
- package/hooks/useRequest/useRequest.js +3 -4
- package/hooks/useRequestHandler/index.d.ts +1 -0
- package/hooks/useRequestHandler/index.es6.js +1 -0
- package/hooks/useRequestHandler/index.js +10 -0
- package/hooks/useRequestHandler/useRequestHandler.d.ts +4 -0
- package/hooks/useRequestHandler/useRequestHandler.es6.js +14 -0
- package/hooks/useRequestHandler/useRequestHandler.js +19 -0
- package/hooks/useResponse/index.es6.js +1 -1
- package/hooks/useResponse/index.js +0 -1
- package/hooks/useResponse/useResponse.d.ts +1 -5
- package/hooks/useResponse/useResponse.es6.js +4 -4
- package/hooks/useResponse/useResponse.js +3 -4
- package/hooks/useSchemaType/useSchemaType.d.ts +3 -2
- package/hooks/useSchemaType/useSchemaType.es6.js +16 -9
- package/hooks/useSchemaType/useSchemaType.js +16 -9
- package/hooks/useServer/useServer.d.ts +2 -3
- package/hooks/useServer/useServer.es6.js +3 -1
- package/hooks/useServer/useServer.js +3 -1
- package/hooks/useServerPlugin/index.d.ts +1 -0
- package/hooks/useServerPlugin/index.es6.js +1 -0
- package/hooks/useServerPlugin/index.js +9 -0
- package/hooks/useServerPlugin/useServerPlugin.d.ts +2 -0
- package/hooks/useServerPlugin/useServerPlugin.es6.js +13 -0
- package/hooks/useServerPlugin/useServerPlugin.js +17 -0
- package/hooks/useServerPlugins/index.d.ts +1 -0
- package/hooks/useServerPlugins/index.es6.js +1 -0
- package/hooks/useServerPlugins/index.js +10 -0
- package/hooks/useServerPlugins/useServerPlugins.d.ts +4 -0
- package/hooks/useServerPlugins/useServerPlugins.es6.js +14 -0
- package/hooks/useServerPlugins/useServerPlugins.js +19 -0
- package/hooks/useServerPort/index.d.ts +1 -0
- package/hooks/useServerPort/index.es6.js +1 -0
- package/hooks/useServerPort/index.js +10 -0
- package/hooks/useServerPort/useServerPort.d.ts +3 -0
- package/hooks/useServerPort/useServerPort.es6.js +14 -0
- package/hooks/useServerPort/useServerPort.js +19 -0
- package/index.d.ts +2 -2
- package/index.es6.js +91 -82
- package/index.js +208 -184
- package/package.json +16 -16
- package/plugins/handler/serverFn/serverFn.es6.js +2 -2
- package/plugins/handler/serverFn/serverFn.js +2 -6
- package/plugins/index.d.ts +2 -2
- package/plugins/index.es6.js +2 -2
- package/plugins/index.js +2 -2
- package/plugins/main/api/api.d.ts +11 -8
- package/plugins/main/api/api.es6.js +112 -113
- package/plugins/main/api/api.js +112 -117
- package/plugins/main/body/body.d.ts +1 -0
- package/plugins/main/body/body.es6.js +4 -4
- package/plugins/main/body/body.js +4 -8
- package/plugins/main/contact/contact.d.ts +2 -2
- package/plugins/main/endpoint/endpoint.d.ts +21 -15
- package/plugins/main/endpoint/endpoint.es6.js +12 -10
- package/plugins/main/endpoint/endpoint.js +11 -13
- package/plugins/main/host/host.d.ts +5 -5
- package/plugins/main/host/host.es6.js +4 -2
- package/plugins/main/host/host.js +4 -6
- package/plugins/main/index.d.ts +9 -9
- package/plugins/main/index.es6.js +9 -9
- package/plugins/main/index.js +9 -9
- package/plugins/main/license/license.d.ts +5 -5
- package/plugins/main/param/param.d.ts +12 -11
- package/plugins/main/param/param.es6.js +7 -8
- package/plugins/main/param/param.js +6 -11
- package/plugins/main/preset/index.d.ts +1 -0
- package/plugins/main/preset/index.es6.js +1 -0
- package/plugins/{utils/prod → main/preset}/index.js +2 -2
- package/plugins/main/preset/preset.d.ts +3 -0
- package/plugins/main/preset/preset.es6.js +13 -0
- package/plugins/main/preset/preset.js +17 -0
- package/plugins/main/response/index.es6.js +1 -1
- package/plugins/main/response/index.js +1 -0
- package/plugins/main/response/response.d.ts +6 -1
- package/plugins/main/response/response.es6.js +29 -13
- package/plugins/main/response/response.js +28 -15
- package/plugins/main/return/index.d.ts +1 -0
- package/plugins/main/return/index.es6.js +1 -0
- package/plugins/main/return/index.js +9 -0
- package/plugins/main/return/return.d.ts +4 -0
- package/plugins/main/return/return.es6.js +10 -0
- package/plugins/main/return/return.js +14 -0
- package/plugins/main/server/server.d.ts +6 -6
- package/plugins/main/server/server.es6.js +40 -16
- package/plugins/main/server/server.js +39 -16
- package/plugins/main/tag/index.es6.js +1 -1
- package/plugins/main/tag/index.js +1 -0
- package/plugins/main/tag/tag.d.ts +10 -2
- package/plugins/main/tag/tag.es6.js +25 -6
- package/plugins/main/tag/tag.js +24 -8
- package/plugins/main/variable/variable.d.ts +5 -5
- package/plugins/main/variable/variable.es6.js +4 -3
- package/plugins/main/variable/variable.js +4 -3
- package/plugins/request/cms/cms.d.ts +1 -0
- package/plugins/request/cms/cms.es6.js +4 -5
- package/plugins/request/cms/cms.js +3 -5
- package/plugins/request/cookie/cookie.d.ts +2 -2
- package/plugins/request/cookie/cookie.es6.js +1 -2
- package/plugins/request/cookie/cookie.js +1 -2
- package/plugins/request/error/error.d.ts +41 -40
- package/plugins/request/error/error.es6.js +47 -45
- package/plugins/request/error/error.js +46 -44
- package/plugins/request/file/file.d.ts +1 -0
- package/plugins/request/file/file.es6.js +5 -7
- package/plugins/request/file/file.js +3 -6
- package/plugins/request/header/header.es6.js +1 -1
- package/plugins/request/header/header.js +1 -1
- package/plugins/request/index.d.ts +5 -5
- package/plugins/request/index.es6.js +5 -5
- package/plugins/request/index.js +5 -5
- package/plugins/request/proxy/proxy.d.ts +3 -1
- package/plugins/request/proxy/proxy.es6.js +5 -2
- package/plugins/request/proxy/proxy.js +5 -2
- package/plugins/request/redirect/redirect.d.ts +8 -7
- package/plugins/request/redirect/redirect.es6.js +7 -7
- package/plugins/request/redirect/redirect.js +7 -7
- package/plugins/request/success/success.d.ts +8 -6
- package/plugins/request/success/success.es6.js +21 -11
- package/plugins/request/success/success.js +20 -10
- package/plugins/schema/any/any.d.ts +5 -0
- package/plugins/schema/any/any.es6.js +27 -0
- package/plugins/schema/any/any.js +31 -0
- package/plugins/schema/array/array.d.ts +4 -0
- package/plugins/schema/array/array.es6.js +15 -7
- package/plugins/schema/array/array.js +15 -11
- package/plugins/schema/binary/binary.d.ts +7 -3
- package/plugins/schema/boolean/boolean.d.ts +1 -0
- package/plugins/schema/date/date.d.ts +3 -2
- package/plugins/schema/date/date.es6.js +8 -4
- package/plugins/schema/date/date.js +8 -4
- package/plugins/schema/field/field.d.ts +6 -0
- package/plugins/schema/field/field.es6.js +22 -9
- package/plugins/schema/field/field.js +20 -11
- package/plugins/schema/index.d.ts +8 -7
- package/plugins/schema/index.es6.js +8 -7
- package/plugins/schema/index.js +8 -7
- package/plugins/schema/integer/integer.d.ts +40 -3
- package/plugins/schema/integer/integer.es6.js +29 -9
- package/plugins/schema/integer/integer.js +29 -9
- package/plugins/schema/number/number.d.ts +34 -2
- package/plugins/schema/number/number.es6.js +21 -6
- package/plugins/schema/number/number.js +21 -6
- package/plugins/schema/object/object.d.ts +1 -0
- package/plugins/schema/object/object.es6.js +22 -8
- package/plugins/schema/object/object.js +21 -11
- package/plugins/schema/string/string.d.ts +29 -2
- package/plugins/schema/string/string.es6.js +50 -31
- package/plugins/schema/string/string.js +50 -31
- package/plugins/schema/tuple/tuple.d.ts +1 -0
- package/plugins/schema/tuple/tuple.es6.js +8 -9
- package/plugins/schema/tuple/tuple.js +7 -12
- package/plugins/schema/uuid/uuid.es6.js +5 -3
- package/plugins/schema/uuid/uuid.js +5 -3
- package/plugins/utils/blacklist/blacklist.d.ts +5 -0
- package/plugins/utils/blacklist/blacklist.es6.js +17 -0
- package/plugins/utils/blacklist/blacklist.js +21 -0
- package/plugins/utils/blacklist/index.d.ts +1 -0
- package/plugins/utils/blacklist/index.es6.js +1 -0
- package/plugins/utils/blacklist/index.js +9 -0
- package/plugins/utils/dts/dts.d.ts +2 -1
- package/plugins/utils/dts/dts.es6.js +6 -3
- package/plugins/utils/dts/dts.js +6 -3
- package/plugins/utils/env/env.d.ts +7 -0
- package/plugins/utils/env/env.es6.js +11 -0
- package/plugins/utils/env/env.js +15 -0
- package/plugins/utils/env/index.d.ts +1 -0
- package/plugins/utils/env/index.es6.js +1 -0
- package/plugins/utils/{dev → env}/index.js +2 -2
- package/plugins/utils/index.d.ts +5 -3
- package/plugins/utils/index.es6.js +5 -3
- package/plugins/utils/index.js +5 -3
- package/plugins/utils/protection/protection.d.ts +4 -4
- package/plugins/utils/protection/protection.es6.js +13 -16
- package/plugins/utils/protection/protection.js +13 -16
- package/plugins/utils/swagger/swagger.d.ts +1 -0
- package/plugins/utils/swagger/swagger.es6.js +8 -5
- package/plugins/utils/swagger/swagger.js +8 -5
- package/plugins/utils/ui/index.d.ts +1 -0
- package/plugins/utils/ui/index.es6.js +1 -0
- package/plugins/utils/ui/index.js +10 -0
- package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
- package/plugins/utils/ui/rapidoc.html.js +7 -0
- package/plugins/utils/ui/redoc.html.es6.js +3 -0
- package/plugins/utils/ui/redoc.html.js +7 -0
- package/plugins/utils/ui/scalar.html.es6.js +3 -0
- package/plugins/utils/ui/scalar.html.js +7 -0
- package/plugins/utils/ui/swagger.html.es6.js +3 -0
- package/plugins/utils/ui/swagger.html.js +7 -0
- package/plugins/utils/ui/ui.d.ts +13 -0
- package/plugins/utils/ui/ui.es6.js +45 -0
- package/plugins/utils/ui/ui.js +50 -0
- package/plugins/utils/whitelist/index.d.ts +1 -0
- package/plugins/utils/whitelist/index.es6.js +1 -0
- package/plugins/utils/whitelist/index.js +9 -0
- package/plugins/utils/whitelist/whitelist.d.ts +5 -0
- package/plugins/utils/whitelist/whitelist.es6.js +19 -0
- package/plugins/utils/whitelist/whitelist.js +23 -0
- package/types.d.ts +21 -22
- package/utils/FileData/Bin.d.ts +13 -13
- package/utils/FileData/Bin.es6.js +2 -2
- package/utils/FileData/Bin.js +2 -2
- package/utils/action/Action.d.ts +13 -14
- package/utils/action/Action.es6.js +92 -92
- package/utils/action/Action.js +91 -91
- package/utils/dateFormat/dateFormat.d.ts +1 -1
- package/utils/dateFormat/dateFormat.es6.js +1 -1
- package/utils/dateFormat/dateFormat.js +1 -1
- package/utils/decorators/once/once.es6.js +1 -1
- package/utils/decorators/once/once.js +1 -1
- package/utils/generateTypes/generateTypes.d.ts +2 -2
- package/utils/generateTypes/generateTypes.es6.js +85 -25
- package/utils/generateTypes/generateTypes.js +85 -25
- package/utils/getEndpoint/getEndpoint.es6.js +2 -2
- package/utils/getEndpoint/getEndpoint.js +2 -2
- package/utils/getOrAdd/getOrAdd.d.ts +1 -1
- package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
- package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
- package/utils/getSafeSchema/getSafeSchema.js +9 -0
- package/utils/getSafeSchema/index.d.ts +1 -0
- package/utils/getSafeSchema/index.es6.js +1 -0
- package/utils/getSafeSchema/index.js +9 -0
- package/utils/httpOnStart/httpOnStart.d.ts +1 -1
- package/utils/httpOnStart/httpOnStart.es6.js +1 -1
- package/utils/httpOnStart/httpOnStart.js +1 -1
- package/utils/index.d.ts +9 -8
- package/utils/index.es6.js +9 -8
- package/utils/index.js +9 -8
- package/utils/parseBody/parseBody.d.ts +0 -1
- package/utils/parseBody/parseBody.es6.js +13 -16
- package/utils/parseBody/parseBody.js +13 -16
- package/utils/parseFormBody/parseFormBody.d.ts +0 -1
- package/utils/parseFormBody/parseFormBody.es6.js +41 -41
- package/utils/parseFormBody/parseFormBody.js +41 -41
- package/utils/parseSearch/parseSearch.es6.js +4 -1
- package/utils/parseSearch/parseSearch.js +4 -1
- package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
- package/utils/rules/arrayOf/arrayOf.js +1 -1
- package/utils/rules/bin/bin.es6.js +4 -1
- package/utils/rules/bin/bin.js +4 -1
- package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
- package/utils/rules/binaryAccept/binaryAccept.js +5 -2
- package/utils/rules/dateTo/dateTo.d.ts +1 -1
- package/utils/rules/dateTo/dateTo.es6.js +4 -1
- package/utils/rules/dateTo/dateTo.js +4 -1
- package/utils/rules/helpers.d.ts +1 -1
- package/utils/rules/helpers.es6.js +4 -1
- package/utils/rules/helpers.js +4 -1
- package/utils/rules/index.d.ts +17 -18
- package/utils/rules/index.es6.js +17 -18
- package/utils/rules/index.js +18 -19
- package/utils/rules/int/int.es6.js +17 -4
- package/utils/rules/int/int.js +17 -4
- package/utils/rules/max/max.d.ts +1 -1
- package/utils/rules/max/max.es6.js +10 -4
- package/utils/rules/max/max.js +10 -4
- package/utils/rules/maxBin/maxBin.es6.js +5 -2
- package/utils/rules/maxBin/maxBin.js +5 -2
- package/utils/rules/maxDate/maxDate.es6.js +5 -1
- package/utils/rules/maxDate/maxDate.js +5 -1
- package/utils/rules/maxLength/maxLength.es6.js +5 -2
- package/utils/rules/maxLength/maxLength.js +5 -2
- package/utils/rules/min/min.d.ts +1 -1
- package/utils/rules/min/min.es6.js +10 -4
- package/utils/rules/min/min.js +10 -4
- package/utils/rules/minBin/minBin.es6.js +5 -2
- package/utils/rules/minBin/minBin.js +5 -2
- package/utils/rules/minDate/minDate.es6.js +5 -1
- package/utils/rules/minDate/minDate.js +5 -1
- package/utils/rules/minLength/minLength.es6.js +5 -2
- package/utils/rules/minLength/minLength.js +5 -2
- package/utils/rules/num/num.es6.js +4 -1
- package/utils/rules/num/num.js +4 -1
- package/utils/rules/objectOf/objectOf.d.ts +1 -1
- package/utils/rules/objectOf/objectOf.es6.js +16 -3
- package/utils/rules/objectOf/objectOf.js +16 -3
- package/utils/rules/pattern/pattern.d.ts +1 -1
- package/utils/rules/pattern/pattern.es6.js +6 -1
- package/utils/rules/pattern/pattern.js +6 -1
- package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
- package/utils/rules/tupleOf/tupleOf.js +1 -1
- package/utils/rules/values/values.es6.js +5 -2
- package/utils/rules/values/values.js +5 -2
- package/utils/stringifySearch/stringifySearch.es6.js +4 -1
- package/utils/stringifySearch/stringifySearch.js +4 -1
- package/example/app/App/App.d.ts +0 -1
- package/example/app/App/index.d.ts +0 -1
- package/example/index.d.ts +0 -1
- package/example/requests/index.d.ts +0 -1
- package/example/requests/todo/AddTodo/AddTodo.d.ts +0 -1
- package/example/requests/todo/AddTodo/index.d.ts +0 -1
- package/example/requests/todo/DeleteTodo/DeleteTodo.d.ts +0 -1
- package/example/requests/todo/DeleteTodo/index.d.ts +0 -1
- package/example/requests/todo/EditTodo/EditTodo.d.ts +0 -1
- package/example/requests/todo/EditTodo/index.d.ts +0 -1
- package/example/requests/todo/GetTodo/GetTodo.d.ts +0 -1
- package/example/requests/todo/GetTodo/index.d.ts +0 -1
- package/example/requests/todo/GetTodos/GetTodos.d.ts +0 -1
- package/example/requests/todo/GetTodos/index.d.ts +0 -1
- package/example/requests/todo/index.d.ts +0 -5
- package/example/requests/todo/todos.d.ts +0 -1
- package/example/schemas/app/ListQueryParams/ListQueryParams.d.ts +0 -1
- package/example/schemas/app/ListQueryParams/index.d.ts +0 -1
- package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -4
- package/example/schemas/app/ListSchema/index.d.ts +0 -1
- package/example/schemas/app/index.d.ts +0 -2
- package/example/schemas/index.d.ts +0 -2
- package/example/schemas/todo/TodoSchema/TodoSchema.d.ts +0 -4
- package/example/schemas/todo/TodoSchema/index.d.ts +0 -1
- package/example/schemas/todo/index.d.ts +0 -1
- package/example/tags/Todo/Todo.d.ts +0 -1
- package/example/tags/Todo/index.d.ts +0 -1
- package/example/tags/index.d.ts +0 -1
- package/hooks/useRequestPlugin/index.d.ts +0 -1
- package/hooks/useRequestPlugin/index.es6.js +0 -1
- package/hooks/useRequestPlugin/index.js +0 -9
- package/hooks/useRequestPlugin/useRequestPlugin.d.ts +0 -2
- package/hooks/useRequestPlugin/useRequestPlugin.es6.js +0 -13
- package/hooks/useRequestPlugin/useRequestPlugin.js +0 -17
- package/openApi.test.d.ts +0 -1
- package/plugins/main/fallback/fallback.d.ts +0 -4
- package/plugins/main/fallback/fallback.es6.js +0 -19
- package/plugins/main/fallback/fallback.js +0 -23
- package/plugins/main/fallback/index.d.ts +0 -1
- package/plugins/main/fallback/index.es6.js +0 -1
- package/plugins/main/fallback/index.js +0 -9
- package/plugins/main/request/index.d.ts +0 -1
- package/plugins/main/request/index.es6.js +0 -1
- package/plugins/main/request/index.js +0 -9
- package/plugins/main/request/request.d.ts +0 -4
- package/plugins/main/request/request.es6.js +0 -21
- package/plugins/main/request/request.js +0 -25
- package/plugins/utils/dev/dev.d.ts +0 -4
- package/plugins/utils/dev/dev.es6.js +0 -10
- package/plugins/utils/dev/dev.js +0 -18
- package/plugins/utils/dev/index.d.ts +0 -1
- package/plugins/utils/dev/index.es6.js +0 -1
- package/plugins/utils/prod/index.d.ts +0 -1
- package/plugins/utils/prod/index.es6.js +0 -1
- package/plugins/utils/prod/prod.d.ts +0 -4
- package/plugins/utils/prod/prod.es6.js +0 -10
- package/plugins/utils/prod/prod.js +0 -18
- package/utils/decorators/once/once.test.d.ts +0 -1
- package/utils/generateTypes/generateTypes.test.d.ts +0 -1
- package/utils/parseSearch/parseSearch.test.d.ts +0 -1
- package/utils/rules/any/any.d.ts +0 -1
- package/utils/rules/any/any.es6.js +0 -5
- package/utils/rules/any/any.js +0 -9
- /package/{utils/rules → plugins/schema}/any/index.d.ts +0 -0
- /package/{utils/rules → plugins/schema}/any/index.es6.js +0 -0
- /package/{utils/rules → plugins/schema}/any/index.js +0 -0
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { __awaiter, __rest } from 'tslib';
|
|
2
1
|
import { Form } from 'multiparty';
|
|
3
2
|
import '../FileData/index.es6.js';
|
|
4
3
|
import '../parseSearch/index.es6.js';
|
|
5
4
|
import { Bin } from '../FileData/Bin.es6.js';
|
|
6
5
|
import { parseSearch } from '../parseSearch/parseSearch.es6.js';
|
|
7
6
|
|
|
8
|
-
function parseFormBody(req) {
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
query += '&';
|
|
23
|
-
}
|
|
24
|
-
query += `${key}=${value.replaceAll('=', '%26')}`;
|
|
7
|
+
async function parseFormBody(req) {
|
|
8
|
+
return await new Promise((resolve, reject) => {
|
|
9
|
+
const form = new Form();
|
|
10
|
+
form.parse(req, (error, fields, files) => {
|
|
11
|
+
if (error) {
|
|
12
|
+
reject(error);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let query = '';
|
|
16
|
+
const queryFiles = [];
|
|
17
|
+
for (const key in fields) {
|
|
18
|
+
for (const value of fields[key]) {
|
|
19
|
+
if (query) {
|
|
20
|
+
query += '&';
|
|
25
21
|
}
|
|
22
|
+
query += `${key}=${value.replaceAll('=', '%26')}`;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
query += `${key}==${queryFiles.length}`;
|
|
34
|
-
const { headers } = value, options = __rest(value, ["headers"]);
|
|
35
|
-
options.type = headers['content-type'];
|
|
36
|
-
options.disposition = headers['content-disposition'];
|
|
37
|
-
queryFiles.push(new Bin(options));
|
|
24
|
+
}
|
|
25
|
+
for (const key in files) {
|
|
26
|
+
const values = files[key];
|
|
27
|
+
for (const value of values) {
|
|
28
|
+
if (query) {
|
|
29
|
+
query += '&';
|
|
38
30
|
}
|
|
31
|
+
query += `${key}==${queryFiles.length}`;
|
|
32
|
+
const { headers, ...options } = value;
|
|
33
|
+
const binOptions = {
|
|
34
|
+
...options,
|
|
35
|
+
disposition: headers['content-disposition'],
|
|
36
|
+
type: headers['content-type'],
|
|
37
|
+
};
|
|
38
|
+
queryFiles.push(new Bin(binOptions));
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
});
|
|
40
|
+
}
|
|
41
|
+
resolve(parseSearch(query, {
|
|
42
|
+
decoder(value, decoder, charset, type) {
|
|
43
|
+
if (type === 'key') {
|
|
44
|
+
return decoder(value, decoder, charset);
|
|
45
|
+
}
|
|
46
|
+
if (value.startsWith('=')) {
|
|
47
|
+
return queryFiles[Number(value.slice(1))];
|
|
48
|
+
}
|
|
49
|
+
return value.replaceAll('%26', '=');
|
|
50
|
+
},
|
|
51
|
+
}));
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -2,57 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var multiparty = require('multiparty');
|
|
7
6
|
require('../FileData/index.js');
|
|
8
7
|
require('../parseSearch/index.js');
|
|
9
8
|
var Bin = require('../FileData/Bin.js');
|
|
10
9
|
var parseSearch = require('../parseSearch/parseSearch.js');
|
|
11
10
|
|
|
12
|
-
function parseFormBody(req) {
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
query += '&';
|
|
27
|
-
}
|
|
28
|
-
query += `${key}=${value.replaceAll('=', '%26')}`;
|
|
11
|
+
async function parseFormBody(req) {
|
|
12
|
+
return await new Promise((resolve, reject) => {
|
|
13
|
+
const form = new multiparty.Form();
|
|
14
|
+
form.parse(req, (error, fields, files) => {
|
|
15
|
+
if (error) {
|
|
16
|
+
reject(error);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let query = '';
|
|
20
|
+
const queryFiles = [];
|
|
21
|
+
for (const key in fields) {
|
|
22
|
+
for (const value of fields[key]) {
|
|
23
|
+
if (query) {
|
|
24
|
+
query += '&';
|
|
29
25
|
}
|
|
26
|
+
query += `${key}=${value.replaceAll('=', '%26')}`;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
query += `${key}==${queryFiles.length}`;
|
|
38
|
-
const { headers } = value, options = tslib.__rest(value, ["headers"]);
|
|
39
|
-
options.type = headers['content-type'];
|
|
40
|
-
options.disposition = headers['content-disposition'];
|
|
41
|
-
queryFiles.push(new Bin.Bin(options));
|
|
28
|
+
}
|
|
29
|
+
for (const key in files) {
|
|
30
|
+
const values = files[key];
|
|
31
|
+
for (const value of values) {
|
|
32
|
+
if (query) {
|
|
33
|
+
query += '&';
|
|
42
34
|
}
|
|
35
|
+
query += `${key}==${queryFiles.length}`;
|
|
36
|
+
const { headers, ...options } = value;
|
|
37
|
+
const binOptions = {
|
|
38
|
+
...options,
|
|
39
|
+
disposition: headers['content-disposition'],
|
|
40
|
+
type: headers['content-type'],
|
|
41
|
+
};
|
|
42
|
+
queryFiles.push(new Bin.Bin(binOptions));
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
});
|
|
44
|
+
}
|
|
45
|
+
resolve(parseSearch.parseSearch(query, {
|
|
46
|
+
decoder(value, decoder, charset, type) {
|
|
47
|
+
if (type === 'key') {
|
|
48
|
+
return decoder(value, decoder, charset);
|
|
49
|
+
}
|
|
50
|
+
if (value.startsWith('=')) {
|
|
51
|
+
return queryFiles[Number(value.slice(1))];
|
|
52
|
+
}
|
|
53
|
+
return value.replaceAll('%26', '=');
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -4,7 +4,10 @@ const EMPTY_SEARCH = {};
|
|
|
4
4
|
function parseSearch(search, options) {
|
|
5
5
|
if (!search)
|
|
6
6
|
return EMPTY_SEARCH;
|
|
7
|
-
return qs.parse(search,
|
|
7
|
+
return qs.parse(search, {
|
|
8
|
+
ignoreQueryPrefix: true,
|
|
9
|
+
...options,
|
|
10
|
+
});
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export { EMPTY_SEARCH, parseSearch };
|
|
@@ -12,7 +12,10 @@ const EMPTY_SEARCH = {};
|
|
|
12
12
|
function parseSearch(search, options) {
|
|
13
13
|
if (!search)
|
|
14
14
|
return EMPTY_SEARCH;
|
|
15
|
-
return qs__default["default"].parse(search,
|
|
15
|
+
return qs__default["default"].parse(search, {
|
|
16
|
+
ignoreQueryPrefix: true,
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
exports.EMPTY_SEARCH = EMPTY_SEARCH;
|
|
@@ -8,7 +8,7 @@ function arrayOf(formatter) {
|
|
|
8
8
|
else if (!Array.isArray(value)) {
|
|
9
9
|
value = [value];
|
|
10
10
|
}
|
|
11
|
-
return value.map((val, index) => formatter(val,
|
|
11
|
+
return value.map((val, index) => formatter(val, { ...data, key: addKey(index, data) }));
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -12,7 +12,7 @@ function arrayOf(formatter) {
|
|
|
12
12
|
else if (!Array.isArray(value)) {
|
|
13
13
|
value = [value];
|
|
14
14
|
}
|
|
15
|
-
return value.map((val, index) => formatter(val,
|
|
15
|
+
return value.map((val, index) => formatter(val, { ...data, key: helpers.addKey(index, data) }));
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -4,7 +4,10 @@ import { Bin } from '../../FileData/Bin.es6.js';
|
|
|
4
4
|
|
|
5
5
|
function bin(value, data) {
|
|
6
6
|
if (!(value instanceof Bin)) {
|
|
7
|
-
throw new RulesError('binary',
|
|
7
|
+
throw new RulesError('binary', {
|
|
8
|
+
value,
|
|
9
|
+
...data,
|
|
10
|
+
});
|
|
8
11
|
}
|
|
9
12
|
return value;
|
|
10
13
|
}
|
package/utils/rules/bin/bin.js
CHANGED
|
@@ -8,7 +8,10 @@ var Bin = require('../../FileData/Bin.js');
|
|
|
8
8
|
|
|
9
9
|
function bin(value, data) {
|
|
10
10
|
if (!(value instanceof Bin.Bin)) {
|
|
11
|
-
throw new helpers.RulesError('binary',
|
|
11
|
+
throw new helpers.RulesError('binary', {
|
|
12
|
+
value,
|
|
13
|
+
...data,
|
|
14
|
+
});
|
|
12
15
|
}
|
|
13
16
|
return value;
|
|
14
17
|
}
|
|
@@ -28,8 +28,11 @@ function binaryAccept(accept) {
|
|
|
28
28
|
continue;
|
|
29
29
|
return value;
|
|
30
30
|
}
|
|
31
|
-
throw new helpers.RulesError('binaryAccept',
|
|
32
|
-
accept
|
|
31
|
+
throw new helpers.RulesError('binaryAccept', {
|
|
32
|
+
accept,
|
|
33
|
+
value,
|
|
34
|
+
...data,
|
|
35
|
+
});
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type DateFormat = 'now' |
|
|
1
|
+
export type DateFormat = 'now' | Date | number | string;
|
|
2
2
|
export declare function dateTo(value: any, data?: object): Date;
|
|
@@ -3,7 +3,10 @@ import { RulesError } from '../helpers.es6.js';
|
|
|
3
3
|
function dateTo(value, data) {
|
|
4
4
|
const result = new Date(value);
|
|
5
5
|
if (isNaN(result)) {
|
|
6
|
-
throw new RulesError('date',
|
|
6
|
+
throw new RulesError('date', {
|
|
7
|
+
value,
|
|
8
|
+
...data,
|
|
9
|
+
});
|
|
7
10
|
}
|
|
8
11
|
return result;
|
|
9
12
|
}
|
|
@@ -7,7 +7,10 @@ var helpers = require('../helpers.js');
|
|
|
7
7
|
function dateTo(value, data) {
|
|
8
8
|
const result = new Date(value);
|
|
9
9
|
if (isNaN(result)) {
|
|
10
|
-
throw new helpers.RulesError('date',
|
|
10
|
+
throw new helpers.RulesError('date', {
|
|
11
|
+
value,
|
|
12
|
+
...data,
|
|
13
|
+
});
|
|
11
14
|
}
|
|
12
15
|
return result;
|
|
13
16
|
}
|
package/utils/rules/helpers.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare class RulesError extends Error {
|
|
|
5
5
|
} & object;
|
|
6
6
|
constructor(error: RulesErrors, data?: object);
|
|
7
7
|
}
|
|
8
|
-
export declare function addKey(key:
|
|
8
|
+
export declare function addKey(key: number | string, data?: any): string | number;
|
package/utils/rules/helpers.js
CHANGED
|
@@ -5,7 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
class RulesError extends Error {
|
|
6
6
|
constructor(error, data) {
|
|
7
7
|
super(`Validation Error: ${error}`);
|
|
8
|
-
this.data =
|
|
8
|
+
this.data = {
|
|
9
|
+
error,
|
|
10
|
+
...data,
|
|
11
|
+
};
|
|
9
12
|
}
|
|
10
13
|
}
|
|
11
14
|
function addKey(key, data) {
|
package/utils/rules/index.d.ts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
export * from './helpers';
|
|
2
|
-
export * from './constants';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from './num';
|
|
5
1
|
export * from './arrayOf';
|
|
6
|
-
export * from './
|
|
2
|
+
export * from './bin';
|
|
3
|
+
export * from './binaryAccept';
|
|
4
|
+
export * from './constants';
|
|
7
5
|
export * from './dateTo';
|
|
6
|
+
export * from './defaultTo';
|
|
7
|
+
export * from './helpers';
|
|
8
8
|
export * from './int';
|
|
9
|
+
export * from './max';
|
|
10
|
+
export * from './maxBin';
|
|
11
|
+
export * from './maxDate';
|
|
12
|
+
export * from './maxLength';
|
|
13
|
+
export * from './min';
|
|
14
|
+
export * from './minBin';
|
|
15
|
+
export * from './minDate';
|
|
16
|
+
export * from './minLength';
|
|
9
17
|
export * from './nullable';
|
|
18
|
+
export * from './num';
|
|
10
19
|
export * from './objectOf';
|
|
20
|
+
export * from './oneOf';
|
|
11
21
|
export * from './optional';
|
|
12
22
|
export * from './pattern';
|
|
23
|
+
export * from './pipe';
|
|
13
24
|
export * from './required';
|
|
14
25
|
export * from './tupleOf';
|
|
26
|
+
export * from './types';
|
|
15
27
|
export * from './uuidTo';
|
|
16
28
|
export * from './values';
|
|
17
|
-
export * from './pipe';
|
|
18
|
-
export * from './maxDate';
|
|
19
|
-
export * from './minDate';
|
|
20
|
-
export * from './maxLength';
|
|
21
|
-
export * from './minLength';
|
|
22
|
-
export * from './max';
|
|
23
|
-
export * from './min';
|
|
24
|
-
export * from './defaultTo';
|
|
25
|
-
export * from './any';
|
|
26
|
-
export * from './bin';
|
|
27
|
-
export * from './minBin';
|
|
28
|
-
export * from './maxBin';
|
|
29
|
-
export * from './binaryAccept';
|
package/utils/rules/index.es6.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
export { RulesError, addKey } from './helpers.es6.js';
|
|
2
|
-
export { rulesErrors } from './constants.es6.js';
|
|
3
|
-
import './types.es6.js';
|
|
4
|
-
import './num/index.es6.js';
|
|
5
1
|
import './arrayOf/index.es6.js';
|
|
6
|
-
import './
|
|
2
|
+
import './bin/index.es6.js';
|
|
3
|
+
import './binaryAccept/index.es6.js';
|
|
4
|
+
export { rulesErrors } from './constants.es6.js';
|
|
7
5
|
import './dateTo/index.es6.js';
|
|
6
|
+
import './defaultTo/index.es6.js';
|
|
7
|
+
export { RulesError, addKey } from './helpers.es6.js';
|
|
8
8
|
import './int/index.es6.js';
|
|
9
|
+
import './max/index.es6.js';
|
|
10
|
+
import './maxBin/index.es6.js';
|
|
11
|
+
import './maxDate/index.es6.js';
|
|
12
|
+
import './maxLength/index.es6.js';
|
|
13
|
+
import './min/index.es6.js';
|
|
14
|
+
import './minBin/index.es6.js';
|
|
15
|
+
import './minDate/index.es6.js';
|
|
16
|
+
import './minLength/index.es6.js';
|
|
9
17
|
import './nullable/index.es6.js';
|
|
18
|
+
import './num/index.es6.js';
|
|
10
19
|
import './objectOf/index.es6.js';
|
|
20
|
+
import './oneOf/index.es6.js';
|
|
11
21
|
import './optional/index.es6.js';
|
|
12
22
|
import './pattern/index.es6.js';
|
|
23
|
+
import './pipe/index.es6.js';
|
|
13
24
|
import './required/index.es6.js';
|
|
14
25
|
import './tupleOf/index.es6.js';
|
|
26
|
+
import './types.es6.js';
|
|
15
27
|
import './uuidTo/index.es6.js';
|
|
16
28
|
import './values/index.es6.js';
|
|
17
|
-
import './pipe/index.es6.js';
|
|
18
|
-
import './maxDate/index.es6.js';
|
|
19
|
-
import './minDate/index.es6.js';
|
|
20
|
-
import './maxLength/index.es6.js';
|
|
21
|
-
import './minLength/index.es6.js';
|
|
22
|
-
import './max/index.es6.js';
|
|
23
|
-
import './min/index.es6.js';
|
|
24
|
-
import './defaultTo/index.es6.js';
|
|
25
|
-
import './any/index.es6.js';
|
|
26
|
-
import './bin/index.es6.js';
|
|
27
|
-
import './minBin/index.es6.js';
|
|
28
|
-
import './maxBin/index.es6.js';
|
|
29
|
-
import './binaryAccept/index.es6.js';
|
package/utils/rules/index.js
CHANGED
|
@@ -2,38 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var helpers = require('./helpers.js');
|
|
6
|
-
var constants = require('./constants.js');
|
|
7
|
-
require('./types.js');
|
|
8
|
-
require('./num/index.js');
|
|
9
5
|
require('./arrayOf/index.js');
|
|
10
|
-
require('./
|
|
6
|
+
require('./bin/index.js');
|
|
7
|
+
require('./binaryAccept/index.js');
|
|
8
|
+
var constants = require('./constants.js');
|
|
11
9
|
require('./dateTo/index.js');
|
|
10
|
+
require('./defaultTo/index.js');
|
|
11
|
+
var helpers = require('./helpers.js');
|
|
12
12
|
require('./int/index.js');
|
|
13
|
+
require('./max/index.js');
|
|
14
|
+
require('./maxBin/index.js');
|
|
15
|
+
require('./maxDate/index.js');
|
|
16
|
+
require('./maxLength/index.js');
|
|
17
|
+
require('./min/index.js');
|
|
18
|
+
require('./minBin/index.js');
|
|
19
|
+
require('./minDate/index.js');
|
|
20
|
+
require('./minLength/index.js');
|
|
13
21
|
require('./nullable/index.js');
|
|
22
|
+
require('./num/index.js');
|
|
14
23
|
require('./objectOf/index.js');
|
|
24
|
+
require('./oneOf/index.js');
|
|
15
25
|
require('./optional/index.js');
|
|
16
26
|
require('./pattern/index.js');
|
|
27
|
+
require('./pipe/index.js');
|
|
17
28
|
require('./required/index.js');
|
|
18
29
|
require('./tupleOf/index.js');
|
|
30
|
+
require('./types.js');
|
|
19
31
|
require('./uuidTo/index.js');
|
|
20
32
|
require('./values/index.js');
|
|
21
|
-
require('./pipe/index.js');
|
|
22
|
-
require('./maxDate/index.js');
|
|
23
|
-
require('./minDate/index.js');
|
|
24
|
-
require('./maxLength/index.js');
|
|
25
|
-
require('./minLength/index.js');
|
|
26
|
-
require('./max/index.js');
|
|
27
|
-
require('./min/index.js');
|
|
28
|
-
require('./defaultTo/index.js');
|
|
29
|
-
require('./any/index.js');
|
|
30
|
-
require('./bin/index.js');
|
|
31
|
-
require('./minBin/index.js');
|
|
32
|
-
require('./maxBin/index.js');
|
|
33
|
-
require('./binaryAccept/index.js');
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
|
|
36
|
+
exports.rulesErrors = constants.rulesErrors;
|
|
37
37
|
exports.RulesError = helpers.RulesError;
|
|
38
38
|
exports.addKey = helpers.addKey;
|
|
39
|
-
exports.rulesErrors = constants.rulesErrors;
|
|
@@ -20,14 +20,27 @@ function int(format) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
if (validator(result)) {
|
|
23
|
-
throw new RulesError('integer',
|
|
24
|
-
|
|
23
|
+
throw new RulesError('integer', {
|
|
24
|
+
format,
|
|
25
|
+
value,
|
|
26
|
+
...data,
|
|
27
|
+
});
|
|
25
28
|
}
|
|
26
29
|
if (result > sizes[format]) {
|
|
27
|
-
throw new RulesError('integer',
|
|
30
|
+
throw new RulesError('integer', {
|
|
31
|
+
format,
|
|
32
|
+
max: sizes[format],
|
|
33
|
+
value: result,
|
|
34
|
+
...data,
|
|
35
|
+
});
|
|
28
36
|
}
|
|
29
37
|
if (result < -sizes[format]) {
|
|
30
|
-
throw new RulesError('integer',
|
|
38
|
+
throw new RulesError('integer', {
|
|
39
|
+
format,
|
|
40
|
+
min: -sizes[format],
|
|
41
|
+
value: result,
|
|
42
|
+
...data,
|
|
43
|
+
});
|
|
31
44
|
}
|
|
32
45
|
return result;
|
|
33
46
|
};
|
package/utils/rules/int/int.js
CHANGED
|
@@ -24,14 +24,27 @@ function int(format) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
if (validator(result)) {
|
|
27
|
-
throw new helpers.RulesError('integer',
|
|
28
|
-
|
|
27
|
+
throw new helpers.RulesError('integer', {
|
|
28
|
+
format,
|
|
29
|
+
value,
|
|
30
|
+
...data,
|
|
31
|
+
});
|
|
29
32
|
}
|
|
30
33
|
if (result > sizes[format]) {
|
|
31
|
-
throw new helpers.RulesError('integer',
|
|
34
|
+
throw new helpers.RulesError('integer', {
|
|
35
|
+
format,
|
|
36
|
+
max: sizes[format],
|
|
37
|
+
value: result,
|
|
38
|
+
...data,
|
|
39
|
+
});
|
|
32
40
|
}
|
|
33
41
|
if (result < -sizes[format]) {
|
|
34
|
-
throw new helpers.RulesError('integer',
|
|
42
|
+
throw new helpers.RulesError('integer', {
|
|
43
|
+
format,
|
|
44
|
+
min: -sizes[format],
|
|
45
|
+
value: result,
|
|
46
|
+
...data,
|
|
47
|
+
});
|
|
35
48
|
}
|
|
36
49
|
return result;
|
|
37
50
|
};
|
package/utils/rules/max/max.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function max(max:
|
|
1
|
+
export declare function max(max: bigint | number): (value: any, data?: object) => any;
|
|
@@ -2,12 +2,18 @@ import { RulesError } from '../helpers.es6.js';
|
|
|
2
2
|
|
|
3
3
|
function max(max) {
|
|
4
4
|
return (value, data) => {
|
|
5
|
-
if (!['
|
|
6
|
-
throw new RulesError('number',
|
|
5
|
+
if (!['bigint', 'number'].includes(typeof value)) {
|
|
6
|
+
throw new RulesError('number', {
|
|
7
|
+
...data,
|
|
8
|
+
value,
|
|
9
|
+
});
|
|
7
10
|
}
|
|
8
11
|
if (value > max) {
|
|
9
|
-
throw new RulesError('maximum',
|
|
10
|
-
|
|
12
|
+
throw new RulesError('maximum', {
|
|
13
|
+
...data,
|
|
14
|
+
max,
|
|
15
|
+
value,
|
|
16
|
+
});
|
|
11
17
|
}
|
|
12
18
|
return value;
|
|
13
19
|
};
|
package/utils/rules/max/max.js
CHANGED
|
@@ -6,12 +6,18 @@ var helpers = require('../helpers.js');
|
|
|
6
6
|
|
|
7
7
|
function max(max) {
|
|
8
8
|
return (value, data) => {
|
|
9
|
-
if (!['
|
|
10
|
-
throw new helpers.RulesError('number',
|
|
9
|
+
if (!['bigint', 'number'].includes(typeof value)) {
|
|
10
|
+
throw new helpers.RulesError('number', {
|
|
11
|
+
...data,
|
|
12
|
+
value,
|
|
13
|
+
});
|
|
11
14
|
}
|
|
12
15
|
if (value > max) {
|
|
13
|
-
throw new helpers.RulesError('maximum',
|
|
14
|
-
|
|
16
|
+
throw new helpers.RulesError('maximum', {
|
|
17
|
+
...data,
|
|
18
|
+
max,
|
|
19
|
+
value,
|
|
20
|
+
});
|
|
15
21
|
}
|
|
16
22
|
return value;
|
|
17
23
|
};
|
|
@@ -3,8 +3,11 @@ import { RulesError } from '../helpers.es6.js';
|
|
|
3
3
|
function maxBin(max) {
|
|
4
4
|
return (value, data) => {
|
|
5
5
|
if (value.size > max) {
|
|
6
|
-
throw new RulesError('maxBin',
|
|
7
|
-
max
|
|
6
|
+
throw new RulesError('maxBin', {
|
|
7
|
+
max,
|
|
8
|
+
value,
|
|
9
|
+
...data,
|
|
10
|
+
});
|
|
8
11
|
}
|
|
9
12
|
return value;
|
|
10
13
|
};
|