@stacksjs/validation 0.57.3 โ 0.58.19
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 +5 -5
- package/dist/index.js +187 -0
- package/package.json +30 -22
- package/LICENSE.md +0 -21
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +0 -4
- package/dist/is.mjs +0 -82
- package/dist/rules.mjs +0 -15
- package/dist/types/env.mjs +0 -105
- package/dist/types/index.mjs +0 -2
- package/dist/types/money.mjs +0 -13
- package/dist/validate.mjs +0 -13
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ This package contains the Stacks Validation system.
|
|
|
9
9
|
## ๐ค Usage
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
12
|
+
bun install -d @stacksjs/validation
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Now, you can use it in your project:
|
|
@@ -20,12 +20,12 @@ import { validate } from '@stacksjs/validation'
|
|
|
20
20
|
// wip
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
To view the full documentation, please visit [https://stacksjs.
|
|
23
|
+
To view the full documentation, please visit [https://stacksjs.org/validation](https://stacksjs.org/validation).
|
|
24
24
|
|
|
25
25
|
## ๐งช Testing
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
|
|
28
|
+
bun test
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## ๐ Changelog
|
|
@@ -44,10 +44,10 @@ For help, discussion about best practices, or any other conversation that would
|
|
|
44
44
|
|
|
45
45
|
For casual chit-chat with others using this package:
|
|
46
46
|
|
|
47
|
-
[Join the Stacks Discord Server](https://discord.
|
|
47
|
+
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
|
|
48
48
|
|
|
49
49
|
## ๐ License
|
|
50
50
|
|
|
51
51
|
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
|
52
52
|
|
|
53
|
-
Made with
|
|
53
|
+
Made with ๐
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/is.ts
|
|
3
|
+
import {toString} from "@stacksjs/strings";
|
|
4
|
+
import {getTypeName} from "@stacksjs/types";
|
|
5
|
+
function isDef(val) {
|
|
6
|
+
return typeof val !== "undefined";
|
|
7
|
+
}
|
|
8
|
+
function isBoolean(val) {
|
|
9
|
+
return typeof val === "boolean";
|
|
10
|
+
}
|
|
11
|
+
function isFunction(val) {
|
|
12
|
+
return typeof val === "function";
|
|
13
|
+
}
|
|
14
|
+
function isNumber(val) {
|
|
15
|
+
return typeof val === "number";
|
|
16
|
+
}
|
|
17
|
+
function isString(val) {
|
|
18
|
+
return typeof val === "string";
|
|
19
|
+
}
|
|
20
|
+
function isObject(val) {
|
|
21
|
+
return toString(val) === "[object Object]";
|
|
22
|
+
}
|
|
23
|
+
function isWindow(val) {
|
|
24
|
+
return typeof window !== "undefined" && toString(val) === "[object Window]";
|
|
25
|
+
}
|
|
26
|
+
function isMap(val) {
|
|
27
|
+
return toString(val) === "[object Map]";
|
|
28
|
+
}
|
|
29
|
+
function isSet(val) {
|
|
30
|
+
return toString(val) === "[object Set]";
|
|
31
|
+
}
|
|
32
|
+
function isPromise(val) {
|
|
33
|
+
return toString(val) === "[object Promise]";
|
|
34
|
+
}
|
|
35
|
+
function isUndefined(v) {
|
|
36
|
+
return getTypeName(v) === "undefined";
|
|
37
|
+
}
|
|
38
|
+
function isNull(v) {
|
|
39
|
+
return getTypeName(v) === "null";
|
|
40
|
+
}
|
|
41
|
+
function isSymbol(v) {
|
|
42
|
+
return getTypeName(v) === "symbol";
|
|
43
|
+
}
|
|
44
|
+
function isDate(v) {
|
|
45
|
+
return getTypeName(v) === "date";
|
|
46
|
+
}
|
|
47
|
+
function isRegExp(v) {
|
|
48
|
+
return getTypeName(v) === "regexp";
|
|
49
|
+
}
|
|
50
|
+
function isArray(v) {
|
|
51
|
+
return getTypeName(v) === "array";
|
|
52
|
+
}
|
|
53
|
+
function isPrimitive(v) {
|
|
54
|
+
const type = getTypeName(v);
|
|
55
|
+
return type === "null" || type === "undefined" || type === "string" || type === "number" || type === "boolean" || type === "symbol";
|
|
56
|
+
}
|
|
57
|
+
function isInteger(v) {
|
|
58
|
+
return isNumber(v) && Number.isInteger(v);
|
|
59
|
+
}
|
|
60
|
+
function isFloat(v) {
|
|
61
|
+
return isNumber(v) && !Number.isInteger(v);
|
|
62
|
+
}
|
|
63
|
+
function isPositive(v) {
|
|
64
|
+
return isNumber(v) && v > 0;
|
|
65
|
+
}
|
|
66
|
+
function isNegative(v) {
|
|
67
|
+
return isNumber(v) && v < 0;
|
|
68
|
+
}
|
|
69
|
+
function isEven(v) {
|
|
70
|
+
return isNumber(v) && v % 2 === 0;
|
|
71
|
+
}
|
|
72
|
+
function isOdd(v) {
|
|
73
|
+
return isNumber(v) && v % 2 !== 0;
|
|
74
|
+
}
|
|
75
|
+
function isEvenOrOdd(v) {
|
|
76
|
+
return isNumber(v) && (v % 2 === 0 ? "even" : "odd");
|
|
77
|
+
}
|
|
78
|
+
function isPositiveOrNegative(v) {
|
|
79
|
+
return isNumber(v) && (v > 0 ? "positive" : "negative");
|
|
80
|
+
}
|
|
81
|
+
function isIntegerOrFloat(v) {
|
|
82
|
+
return isNumber(v) && (Number.isInteger(v) ? "integer" : "float");
|
|
83
|
+
}
|
|
84
|
+
var isBrowser = typeof window !== "undefined";
|
|
85
|
+
var isServer = typeof document === "undefined";
|
|
86
|
+
// src/rules.ts
|
|
87
|
+
import {USD} from "@dinero.js/currencies";
|
|
88
|
+
import {dinero as currency} from "dinero.js";
|
|
89
|
+
|
|
90
|
+
// src/validate.ts
|
|
91
|
+
import v, {Vine as Validator} from "@vinejs/vine";
|
|
92
|
+
|
|
93
|
+
// src/types/money.ts
|
|
94
|
+
import {BaseLiteralType} from "@vinejs/vine";
|
|
95
|
+
class MoneyValidator extends BaseLiteralType {
|
|
96
|
+
constructor(options, validations) {
|
|
97
|
+
super(options, validations || [isMoney()]);
|
|
98
|
+
}
|
|
99
|
+
clone() {
|
|
100
|
+
return new MoneyValidator(this.cloneOptions(), this.cloneValidations());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/validate.ts
|
|
105
|
+
import {VineString, VineBoolean, VineEnum, VineNumber} from "@vinejs/vine";
|
|
106
|
+
Validator.macro("money", () => {
|
|
107
|
+
return new MoneyValidator;
|
|
108
|
+
});
|
|
109
|
+
var validator = v;
|
|
110
|
+
var validate = {
|
|
111
|
+
string: (defaultValue = "") => defaultValue,
|
|
112
|
+
number: (defaultValue = 1) => defaultValue,
|
|
113
|
+
boolean: (defaultValue = true) => defaultValue,
|
|
114
|
+
enum: (values) => values
|
|
115
|
+
};
|
|
116
|
+
var RuleString = (...args) => validator.string(...args);
|
|
117
|
+
var RuleNumber = (...args) => validator.number(...args);
|
|
118
|
+
var RuleBoolean = (...args) => validator.boolean(...args);
|
|
119
|
+
var RuleArray = (...args) => validator.array(...args);
|
|
120
|
+
var RuleObject = (...args) => validator.object(...args);
|
|
121
|
+
var RuleAny = (...args) => validator.any(...args);
|
|
122
|
+
|
|
123
|
+
// src/rules.ts
|
|
124
|
+
var isMoney = validator.createRule((value, _, field) => {
|
|
125
|
+
const numericValue = validator.helpers.asNumber(value);
|
|
126
|
+
if (Number.isNaN(numericValue)) {
|
|
127
|
+
field.report("The {{ field }} field value must be a number", "money", field);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const amount = currency({ amount: numericValue, currency: USD });
|
|
131
|
+
field.mutate(amount, field);
|
|
132
|
+
});
|
|
133
|
+
// src/types/index.ts
|
|
134
|
+
import {
|
|
135
|
+
VineEnum as VineEnum2,
|
|
136
|
+
VineBoolean as VineBoolean2,
|
|
137
|
+
VineNumber as VineNumber2,
|
|
138
|
+
VineString as VineString2
|
|
139
|
+
} from "@vinejs/vine";
|
|
140
|
+
export {
|
|
141
|
+
validator,
|
|
142
|
+
validate,
|
|
143
|
+
isWindow,
|
|
144
|
+
isUndefined,
|
|
145
|
+
isSymbol,
|
|
146
|
+
isString,
|
|
147
|
+
isSet,
|
|
148
|
+
isServer,
|
|
149
|
+
isRegExp,
|
|
150
|
+
isPromise,
|
|
151
|
+
isPrimitive,
|
|
152
|
+
isPositiveOrNegative,
|
|
153
|
+
isPositive,
|
|
154
|
+
isOdd,
|
|
155
|
+
isObject,
|
|
156
|
+
isNumber,
|
|
157
|
+
isNull,
|
|
158
|
+
isNegative,
|
|
159
|
+
isMoney,
|
|
160
|
+
isMap,
|
|
161
|
+
isIntegerOrFloat,
|
|
162
|
+
isInteger,
|
|
163
|
+
isFunction,
|
|
164
|
+
isFloat,
|
|
165
|
+
isEvenOrOdd,
|
|
166
|
+
isEven,
|
|
167
|
+
isDef,
|
|
168
|
+
isDate,
|
|
169
|
+
isBrowser,
|
|
170
|
+
isBoolean,
|
|
171
|
+
isArray,
|
|
172
|
+
VineString,
|
|
173
|
+
VineNumber,
|
|
174
|
+
VineEnum,
|
|
175
|
+
VineBoolean,
|
|
176
|
+
VineString2 as ValidationString,
|
|
177
|
+
VineNumber2 as ValidationNumber,
|
|
178
|
+
VineEnum2 as ValidationEnum,
|
|
179
|
+
VineBoolean2 as ValidationBoolean,
|
|
180
|
+
RuleString,
|
|
181
|
+
RuleObject,
|
|
182
|
+
RuleNumber,
|
|
183
|
+
RuleBoolean,
|
|
184
|
+
RuleArray,
|
|
185
|
+
RuleAny,
|
|
186
|
+
MoneyValidator
|
|
187
|
+
};
|
package/package.json
CHANGED
|
@@ -1,55 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/validation",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"
|
|
6
|
-
"description": "The Stacks Validation methods.",
|
|
4
|
+
"version": "0.58.19",
|
|
5
|
+
"description": "The Stacks Validation ways.",
|
|
7
6
|
"author": "Chris Breuer",
|
|
8
7
|
"license": "MIT",
|
|
9
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
|
-
"homepage": "https://github.com/stacksjs/stacks/tree/main
|
|
9
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/src/validation#readme",
|
|
11
10
|
"repository": {
|
|
12
11
|
"type": "git",
|
|
13
12
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
14
|
-
"directory": "
|
|
13
|
+
"directory": "./storage/framework/core/src/validation"
|
|
15
14
|
},
|
|
16
15
|
"bugs": {
|
|
17
16
|
"url": "https://github.com/stacksjs/stacks/issues"
|
|
18
17
|
},
|
|
19
18
|
"keywords": [
|
|
19
|
+
"vinejs",
|
|
20
20
|
"validation",
|
|
21
|
-
"yup",
|
|
22
21
|
"utilities",
|
|
23
22
|
"functions",
|
|
24
23
|
"stacks"
|
|
25
24
|
],
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
|
-
"
|
|
27
|
+
"bun": "./src/index.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./*": {
|
|
31
|
+
"bun": "./*",
|
|
32
|
+
"import": "./dist/*"
|
|
29
33
|
}
|
|
30
34
|
},
|
|
31
|
-
"
|
|
35
|
+
"main": "dist/index.cjs",
|
|
36
|
+
"module": "dist/index.js",
|
|
32
37
|
"contributors": [
|
|
33
|
-
"Chris Breuer <chris@
|
|
38
|
+
"Chris Breuer <chris@stacksjs.org>"
|
|
34
39
|
],
|
|
35
40
|
"files": [
|
|
36
|
-
"
|
|
37
|
-
"
|
|
41
|
+
"README.md",
|
|
42
|
+
"dist"
|
|
38
43
|
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "bun --bun build.ts",
|
|
46
|
+
"typecheck": "bun --bun tsc --noEmit",
|
|
47
|
+
"prepublishOnly": "bun --bun run build"
|
|
48
|
+
},
|
|
39
49
|
"peerDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@stacksjs/
|
|
50
|
+
"@stacksjs/strings": "workspace:*",
|
|
51
|
+
"@stacksjs/types": "workspace:*",
|
|
52
|
+
"@vinejs/vine": "^1.7.0"
|
|
42
53
|
},
|
|
43
54
|
"dependencies": {
|
|
44
|
-
"@
|
|
55
|
+
"@stacksjs/strings": "workspace:*",
|
|
56
|
+
"@stacksjs/types": "workspace:*",
|
|
57
|
+
"@vinejs/vine": "^1.7.0"
|
|
45
58
|
},
|
|
46
59
|
"devDependencies": {
|
|
47
|
-
"@stacksjs/development": "
|
|
48
|
-
"@stacksjs/
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "unbuild",
|
|
52
|
-
"dev": "unbuild --stub",
|
|
53
|
-
"typecheck": "tsc --noEmit"
|
|
60
|
+
"@stacksjs/development": "workspace:*",
|
|
61
|
+
"@stacksjs/vite": "workspace:*"
|
|
54
62
|
}
|
|
55
|
-
}
|
|
63
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Open Web Foundation
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "/home/runner/work/stacks/stacks/.stacks/core/validation/src/index";
|
package/dist/index.mjs
DELETED
package/dist/is.mjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { getTypeName, toString } from "@stacksjs/utils";
|
|
2
|
-
export function isDef(val) {
|
|
3
|
-
return typeof val !== "undefined";
|
|
4
|
-
}
|
|
5
|
-
export function isBoolean(val) {
|
|
6
|
-
return typeof val === "boolean";
|
|
7
|
-
}
|
|
8
|
-
export function isFunction(val) {
|
|
9
|
-
return typeof val === "function";
|
|
10
|
-
}
|
|
11
|
-
export function isNumber(val) {
|
|
12
|
-
return typeof val === "number";
|
|
13
|
-
}
|
|
14
|
-
export function isString(val) {
|
|
15
|
-
return typeof val === "string";
|
|
16
|
-
}
|
|
17
|
-
export function isObject(val) {
|
|
18
|
-
return toString(val) === "[object Object]";
|
|
19
|
-
}
|
|
20
|
-
export function isWindow(val) {
|
|
21
|
-
return typeof window !== "undefined" && toString(val) === "[object Window]";
|
|
22
|
-
}
|
|
23
|
-
export const isBrowser = typeof window !== "undefined";
|
|
24
|
-
export const isServer = typeof document === "undefined";
|
|
25
|
-
export function isMap(val) {
|
|
26
|
-
return toString(val) === "[object Map]";
|
|
27
|
-
}
|
|
28
|
-
export function isSet(val) {
|
|
29
|
-
return toString(val) === "[object Set]";
|
|
30
|
-
}
|
|
31
|
-
export function isPromise(val) {
|
|
32
|
-
return toString(val) === "[object Promise]";
|
|
33
|
-
}
|
|
34
|
-
export function isUndefined(v) {
|
|
35
|
-
return getTypeName(v) === "undefined";
|
|
36
|
-
}
|
|
37
|
-
export function isNull(v) {
|
|
38
|
-
return getTypeName(v) === "null";
|
|
39
|
-
}
|
|
40
|
-
export function isSymbol(v) {
|
|
41
|
-
return getTypeName(v) === "symbol";
|
|
42
|
-
}
|
|
43
|
-
export function isDate(v) {
|
|
44
|
-
return getTypeName(v) === "date";
|
|
45
|
-
}
|
|
46
|
-
export function isRegExp(v) {
|
|
47
|
-
return getTypeName(v) === "regexp";
|
|
48
|
-
}
|
|
49
|
-
export function isArray(v) {
|
|
50
|
-
return getTypeName(v) === "array";
|
|
51
|
-
}
|
|
52
|
-
export function isPrimitive(v) {
|
|
53
|
-
const type = getTypeName(v);
|
|
54
|
-
return type === "null" || type === "undefined" || type === "string" || type === "number" || type === "boolean" || type === "symbol";
|
|
55
|
-
}
|
|
56
|
-
export function isInteger(v) {
|
|
57
|
-
return isNumber(v) && Number.isInteger(v);
|
|
58
|
-
}
|
|
59
|
-
export function isFloat(v) {
|
|
60
|
-
return isNumber(v) && !Number.isInteger(v);
|
|
61
|
-
}
|
|
62
|
-
export function isPositive(v) {
|
|
63
|
-
return isNumber(v) && v > 0;
|
|
64
|
-
}
|
|
65
|
-
export function isNegative(v) {
|
|
66
|
-
return isNumber(v) && v < 0;
|
|
67
|
-
}
|
|
68
|
-
export function isEven(v) {
|
|
69
|
-
return isNumber(v) && v % 2 === 0;
|
|
70
|
-
}
|
|
71
|
-
export function isOdd(v) {
|
|
72
|
-
return isNumber(v) && v % 2 !== 0;
|
|
73
|
-
}
|
|
74
|
-
export function isEvenOrOdd(v) {
|
|
75
|
-
return isNumber(v) && (v % 2 === 0 ? "even" : "odd");
|
|
76
|
-
}
|
|
77
|
-
export function isPositiveOrNegative(v) {
|
|
78
|
-
return isNumber(v) && (v > 0 ? "positive" : "negative");
|
|
79
|
-
}
|
|
80
|
-
export function isIntegerOrFloat(v) {
|
|
81
|
-
return isNumber(v) && (Number.isInteger(v) ? "integer" : "float");
|
|
82
|
-
}
|
package/dist/rules.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { USD, currency } from "@stacksjs/utils";
|
|
2
|
-
import { validator } from "./validate.mjs";
|
|
3
|
-
export const isMoney = validator.createRule((value, _, field) => {
|
|
4
|
-
const numericValue = validator.helpers.asNumber(value);
|
|
5
|
-
if (Number.isNaN(numericValue)) {
|
|
6
|
-
field.report(
|
|
7
|
-
"The {{ field }} field value must be a number",
|
|
8
|
-
"money",
|
|
9
|
-
field
|
|
10
|
-
);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const amount = currency({ amount: numericValue, currency: USD });
|
|
14
|
-
field.mutate(amount, field);
|
|
15
|
-
});
|
package/dist/types/env.mjs
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import validator from "@vinejs/vine";
|
|
3
|
-
import { loadEnv } from "vite";
|
|
4
|
-
import { projectPath } from "@stacksjs/path";
|
|
5
|
-
const envSchema = validator.object({
|
|
6
|
-
APP_NAME: validator.string().optional(),
|
|
7
|
-
APP_ENV: validator.enum(["local", "development", "staging", "production"]).optional(),
|
|
8
|
-
APP_KEY: validator.string().optional(),
|
|
9
|
-
APP_URL: validator.string(),
|
|
10
|
-
APP_DEBUG: validator.boolean().optional(),
|
|
11
|
-
APP_SUBDOMAIN_API: validator.string().optional(),
|
|
12
|
-
APP_SUBDOMAIN_DOCS: validator.string().optional(),
|
|
13
|
-
APP_SUBDOMAIN_LIBRARY: validator.string().optional(),
|
|
14
|
-
APP_BUCKET: validator.string().optional(),
|
|
15
|
-
DB_CONNECTION: validator.string().optional(),
|
|
16
|
-
DB_HOST: validator.string().optional(),
|
|
17
|
-
DB_PORT: validator.number().optional(),
|
|
18
|
-
DB_DATABASE: validator.string().optional(),
|
|
19
|
-
DB_USERNAME: validator.string().optional(),
|
|
20
|
-
DB_PASSWORD: validator.string().optional(),
|
|
21
|
-
SEARCH_ENGINE_DRIVER: validator.string().optional(),
|
|
22
|
-
MEILISEARCH_HOST: validator.string().optional(),
|
|
23
|
-
MEILISEARCH_KEY: validator.string().optional(),
|
|
24
|
-
CACHE_DRIVER: validator.enum(["dynamodb", "memcached", "redis"]).optional(),
|
|
25
|
-
CACHE_PREFIX: validator.string().optional(),
|
|
26
|
-
CACHE_TTL: validator.number().optional(),
|
|
27
|
-
AWS_ACCESS_KEY_ID: validator.string().optional(),
|
|
28
|
-
AWS_SECRET_ACCESS_KEY: validator.string().optional(),
|
|
29
|
-
AWS_DEFAULT_REGION: validator.string().optional(),
|
|
30
|
-
DYNAMODB_CACHE_TABLE: validator.string().optional(),
|
|
31
|
-
DYNAMODB_ENDPOINT: validator.string().optional(),
|
|
32
|
-
MEMCACHED_PERSISTENT_ID: validator.string().optional(),
|
|
33
|
-
MEMCACHED_USERNAME: validator.string().optional(),
|
|
34
|
-
MEMCACHED_PASSWORD: validator.string().optional(),
|
|
35
|
-
MEMCACHED_HOST: validator.string().optional(),
|
|
36
|
-
MEMCACHED_PORT: validator.number().optional(),
|
|
37
|
-
REDIS_HOST: validator.string().optional(),
|
|
38
|
-
REDIS_PORT: validator.number().optional(),
|
|
39
|
-
MAIL_FROM_NAME: validator.string().optional(),
|
|
40
|
-
MAIL_FROM_ADDRESS: validator.string().optional(),
|
|
41
|
-
EMAILJS_HOST: validator.string().optional(),
|
|
42
|
-
EMAILJS_USERNAME: validator.string().optional(),
|
|
43
|
-
EMAILJS_PASSWORD: validator.string().optional(),
|
|
44
|
-
EMAILJS_PORT: validator.number().optional(),
|
|
45
|
-
EMAILJS_SECURE: validator.boolean().optional(),
|
|
46
|
-
MAILGUN_API_KEY: validator.string().optional(),
|
|
47
|
-
MAILGUN_DOMAIN: validator.string().optional(),
|
|
48
|
-
MAILGUN_USERNAME: validator.string().optional(),
|
|
49
|
-
MAILJET_API_KEY: validator.string().optional(),
|
|
50
|
-
MAILJET_API_SECRET: validator.string().optional(),
|
|
51
|
-
MANDRILL_API_KEY: validator.string().optional(),
|
|
52
|
-
NETCORE_API_KEY: validator.string().optional(),
|
|
53
|
-
NODEMAILER_HOST: validator.string().optional(),
|
|
54
|
-
NODEMAILER_USERNAME: validator.string().optional(),
|
|
55
|
-
NODEMAILER_PASSWORD: validator.string().optional(),
|
|
56
|
-
NODEMAILER_PORT: validator.number().optional(),
|
|
57
|
-
NODEMAILER_SECURE: validator.boolean().optional(),
|
|
58
|
-
POSTMARK_API_TOKEN: validator.string().optional(),
|
|
59
|
-
POSTMARK_API_KEY: validator.string().optional(),
|
|
60
|
-
SENDGRID_API_KEY: validator.string().optional(),
|
|
61
|
-
SENDGRID_SENDER_NAME: validator.string().optional(),
|
|
62
|
-
SES_API_VERSION: validator.string().optional(),
|
|
63
|
-
SES_ACCESS_KEY_ID: validator.string().optional(),
|
|
64
|
-
SES_SECRET_ACCESS_KEY: validator.string().optional(),
|
|
65
|
-
SES_REGION: validator.string().optional(),
|
|
66
|
-
FROM_PHONE_NUMBER: validator.string().optional(),
|
|
67
|
-
TWILIO_ACCOUNT_SID: validator.string().optional(),
|
|
68
|
-
TWILIO_AUTH_TOKEN: validator.string().optional(),
|
|
69
|
-
VONAGE_API_KEY: validator.string().optional(),
|
|
70
|
-
VONAGE_API_SECRET: validator.string().optional(),
|
|
71
|
-
GUPSHUP_USER_ID: validator.string().optional(),
|
|
72
|
-
GUPSHUP_PASSWORD: validator.string().optional(),
|
|
73
|
-
PLIVO_ACCOUNT_ID: validator.string().optional(),
|
|
74
|
-
PLIVO_AUTH_TOKEN: validator.string().optional(),
|
|
75
|
-
SMS77_API_KEY: validator.string().optional(),
|
|
76
|
-
SNS_REGION: validator.string().optional(),
|
|
77
|
-
SNS_ACCESS_KEY_ID: validator.string().optional(),
|
|
78
|
-
SNS_SECRET_ACCESS_KEY: validator.string().optional(),
|
|
79
|
-
TELNYX_API_KEY: validator.string().optional(),
|
|
80
|
-
TELNYX_MESSAGE_PROFILE_ID: validator.string().optional(),
|
|
81
|
-
TERMII_API_KEY: validator.string().optional(),
|
|
82
|
-
SLACK_FROM: validator.string().optional(),
|
|
83
|
-
SLACK_APPLICATION_ID: validator.string().optional(),
|
|
84
|
-
SLACK_CLIENT_ID: validator.string().optional(),
|
|
85
|
-
SLACK_SECRET_KEY: validator.string().optional(),
|
|
86
|
-
MICROSOFT_TEAMS_APPLICATION_ID: validator.string().optional(),
|
|
87
|
-
MICROSOFT_TEAMS_CLIENT_ID: validator.string().optional(),
|
|
88
|
-
MICROSOFT_TEAMS_SECRET: validator.string().optional()
|
|
89
|
-
});
|
|
90
|
-
const frontendEnvSchema = validator.object({
|
|
91
|
-
FRONTEND_APP_ENV: validator.enum(["local", "development", "staging", "production"]).optional(),
|
|
92
|
-
FRONTEND_APP_URL: validator.string().optional()
|
|
93
|
-
});
|
|
94
|
-
export const env = process.env;
|
|
95
|
-
export async function getEnv() {
|
|
96
|
-
try {
|
|
97
|
-
const mode = process.env.NODE_ENV ?? "development";
|
|
98
|
-
const data = loadEnv(mode, projectPath(), "");
|
|
99
|
-
const v = validator.compile(envSchema);
|
|
100
|
-
return v.validate(data);
|
|
101
|
-
} catch (error) {
|
|
102
|
-
handleError(error);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
export { loadEnv };
|
package/dist/types/index.mjs
DELETED
package/dist/types/money.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseLiteralType } from "@vinejs/vine";
|
|
2
|
-
import { isMoney } from "../rules.mjs";
|
|
3
|
-
export class MoneyValidator extends BaseLiteralType {
|
|
4
|
-
constructor(options, validations) {
|
|
5
|
-
super(options, validations || [isMoney()]);
|
|
6
|
-
}
|
|
7
|
-
clone() {
|
|
8
|
-
return new MoneyValidator(
|
|
9
|
-
this.cloneOptions(),
|
|
10
|
-
this.cloneValidations()
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
}
|
package/dist/validate.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import validator, { Vine as Validator } from "@vinejs/vine";
|
|
2
|
-
import { MoneyValidator } from "./types/money.mjs";
|
|
3
|
-
Validator.macro("money", () => {
|
|
4
|
-
return new MoneyValidator();
|
|
5
|
-
});
|
|
6
|
-
const validate = validator;
|
|
7
|
-
const string = validator.string();
|
|
8
|
-
const number = validator.number;
|
|
9
|
-
const boolean = validator.boolean;
|
|
10
|
-
const array = validator.array;
|
|
11
|
-
const object = validator.object;
|
|
12
|
-
const any = validator.any;
|
|
13
|
-
export { validate, validator, Validator, string, number, boolean, array, object, any };
|