node-env-resolver 6.5.1 → 6.5.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 +708 -400
- package/dist/builder.cjs +1 -1
- package/dist/builder.d.cts +1 -1
- package/dist/builder.d.ts +1 -1
- package/dist/builder.js +1 -1
- package/dist/chunk-3EWCMDFP.js +9 -0
- package/dist/chunk-BFLXBLZ3.cjs +1 -0
- package/dist/chunk-CDXO2XX3.cjs +2 -0
- package/dist/chunk-CTJYBBOB.js +2 -0
- package/dist/chunk-DIJNUFGZ.cjs +15 -0
- package/dist/chunk-DYFRO3NM.cjs +9 -0
- package/dist/chunk-K4NIC5T3.js +9 -0
- package/dist/chunk-WVMDTD6J.cjs +9 -0
- package/dist/chunk-ZMRT37K3.js +1 -0
- package/dist/chunk-ZSM2NDX5.js +15 -0
- package/dist/cli/bin.cjs +74 -0
- package/dist/cli/bin.js +74 -0
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +1 -1
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.d.cts +1 -1
- package/dist/resolver.d.ts +1 -1
- package/dist/resolver.js +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +2 -27
- package/dist/resolvers.d.ts +2 -27
- package/dist/resolvers.js +1 -1
- package/dist/runtime/index.cjs +1 -0
- package/dist/runtime/index.d.cts +161 -0
- package/dist/runtime/index.d.ts +161 -0
- package/dist/runtime/index.js +1 -0
- package/dist/types--RcOnfdl.d.cts +284 -0
- package/dist/types--RcOnfdl.d.ts +284 -0
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +1 -129
- package/dist/types.d.ts +1 -129
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +56 -12
- package/dist/utils.d.ts +56 -12
- package/dist/utils.js +1 -1
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.cts +12 -25
- package/dist/valibot.d.ts +12 -25
- package/dist/valibot.js +1 -1
- package/dist/validators.cjs +2 -2
- package/dist/validators.d.cts +25 -48
- package/dist/validators.d.ts +25 -48
- package/dist/validators.js +2 -2
- package/dist/web.cjs +5 -5
- package/dist/web.d.cts +3 -1
- package/dist/web.d.ts +3 -1
- package/dist/web.js +5 -5
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.cts +12 -25
- package/dist/zod.d.ts +12 -25
- package/dist/zod.js +1 -1
- package/package.json +28 -40
- package/binding.gyp +0 -9
- package/dist/chunk-2IQQVAXA.cjs +0 -9
- package/dist/chunk-46CBATKM.js +0 -1
- package/dist/chunk-C34FGZOG.js +0 -9
- package/dist/chunk-FNF55TN4.cjs +0 -1
- package/dist/chunk-G36OESVW.cjs +0 -1
- package/dist/chunk-I5UKYTX6.js +0 -1
- package/dist/chunk-MFFH2ZXS.js +0 -17
- package/dist/chunk-QCKMQEJP.cjs +0 -17
- package/dist/chunk-S7AB6UX7.cjs +0 -9
- package/dist/chunk-TGIYWWDY.js +0 -9
- package/dist/chunk-VUUPIWFJ.js +0 -9
- package/dist/chunk-ZDRU3RSU.cjs +0 -9
- package/dist/cli-main.cjs +0 -4
- package/dist/cli-main.js +0 -4
- package/dist/redaction.cjs +0 -1
- package/dist/redaction.d.cts +0 -54
- package/dist/redaction.d.ts +0 -54
- package/dist/redaction.js +0 -1
- package/dist/typegen.cjs +0 -1
- package/dist/typegen.d.cts +0 -52
- package/dist/typegen.d.ts +0 -52
- package/dist/typegen.js +0 -1
- package/index.js +0 -1
- /package/dist/{cli-main.d.cts → cli/bin.d.cts} +0 -0
- /package/dist/{cli-main.d.ts → cli/bin.d.ts} +0 -0
package/dist/valibot.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Resolver, PolicyOptions } from './types.js';
|
|
1
|
+
import { a as Resolver, P as PolicyOptions, b as ReferenceOptions } from './types--RcOnfdl.js';
|
|
2
2
|
import { SafeResolveResult } from './validation-types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -19,6 +19,13 @@ import { SafeResolveResult } from './validation-types.js';
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
type ResolveValibotOptions = {
|
|
23
|
+
resolvers?: Resolver[];
|
|
24
|
+
interpolate?: boolean;
|
|
25
|
+
strict?: boolean;
|
|
26
|
+
policies?: PolicyOptions;
|
|
27
|
+
references?: ReferenceOptions;
|
|
28
|
+
};
|
|
22
29
|
/**
|
|
23
30
|
* Type inference for Valibot schema output
|
|
24
31
|
* Uses Valibot's InferOutput if available, falls back to generic inference
|
|
@@ -49,12 +56,7 @@ type InferValibotOutput<T> = T extends {
|
|
|
49
56
|
*/
|
|
50
57
|
declare function resolveValibot<TSchema extends {
|
|
51
58
|
parseAsync: (input: unknown) => Promise<unknown>;
|
|
52
|
-
}>(valibotSchema: TSchema, options?:
|
|
53
|
-
resolvers?: Resolver[];
|
|
54
|
-
interpolate?: boolean;
|
|
55
|
-
strict?: boolean;
|
|
56
|
-
policies?: PolicyOptions;
|
|
57
|
-
}): Promise<InferValibotOutput<TSchema>>;
|
|
59
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): Promise<InferValibotOutput<TSchema>>;
|
|
58
60
|
/**
|
|
59
61
|
* Safe version - returns result object instead of throwing (unified error format)
|
|
60
62
|
*
|
|
@@ -86,12 +88,7 @@ declare function safeResolveValibot<TSchema extends {
|
|
|
86
88
|
output?: unknown;
|
|
87
89
|
issues?: unknown;
|
|
88
90
|
}>;
|
|
89
|
-
}>(valibotSchema: TSchema, options?:
|
|
90
|
-
resolvers?: Resolver[];
|
|
91
|
-
interpolate?: boolean;
|
|
92
|
-
strict?: boolean;
|
|
93
|
-
policies?: PolicyOptions;
|
|
94
|
-
}): Promise<SafeResolveResult<InferValibotOutput<TSchema>>>;
|
|
91
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): Promise<SafeResolveResult<InferValibotOutput<TSchema>>>;
|
|
95
92
|
/**
|
|
96
93
|
* Sync version of resolveValibot (throws on validation error)
|
|
97
94
|
*
|
|
@@ -110,12 +107,7 @@ declare function safeResolveValibot<TSchema extends {
|
|
|
110
107
|
*/
|
|
111
108
|
declare function resolveSyncValibot<TSchema extends {
|
|
112
109
|
parse: (input: unknown) => unknown;
|
|
113
|
-
}>(valibotSchema: TSchema, options?:
|
|
114
|
-
resolvers?: Resolver[];
|
|
115
|
-
interpolate?: boolean;
|
|
116
|
-
strict?: boolean;
|
|
117
|
-
policies?: PolicyOptions;
|
|
118
|
-
}): InferValibotOutput<TSchema>;
|
|
110
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): InferValibotOutput<TSchema>;
|
|
119
111
|
/**
|
|
120
112
|
* Safe sync version - returns result object instead of throwing (unified error format)
|
|
121
113
|
*
|
|
@@ -146,11 +138,6 @@ declare function safeResolveSyncValibot<TSchema extends {
|
|
|
146
138
|
output?: unknown;
|
|
147
139
|
issues?: unknown;
|
|
148
140
|
};
|
|
149
|
-
}>(valibotSchema: TSchema, options?:
|
|
150
|
-
resolvers?: Resolver[];
|
|
151
|
-
interpolate?: boolean;
|
|
152
|
-
strict?: boolean;
|
|
153
|
-
policies?: PolicyOptions;
|
|
154
|
-
}): SafeResolveResult<InferValibotOutput<TSchema>>;
|
|
141
|
+
}>(valibotSchema: TSchema, options?: ResolveValibotOptions): SafeResolveResult<InferValibotOutput<TSchema>>;
|
|
155
142
|
|
|
156
143
|
export { type InferValibotOutput, resolveSyncValibot, resolveValibot, safeResolveSyncValibot, safeResolveValibot };
|
package/dist/valibot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import'./chunk-ZSM2NDX5.js';import {c,b as b$1}from'./chunk-CTJYBBOB.js';import {a}from'./chunk-WKIPEKF6.js';import'./chunk-I7AUKTXE.js';async function v(o,t,e,c$1){let r={},a={};for(let n of o)try{let s=n.load?await n.load():{};r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return await c(r,a,c$1),{env:r,provenance:a}}function d(o,t,e,c){let r={},a={};for(let n of o)try{if(!n.loadSync){if(e)throw new Error(`Resolver ${n.name} does not support sync loading`);continue}let s=n.loadSync();r={...r,...s};for(let[i,u]of Object.entries(s))u!==void 0&&(a[i]={source:n.name||"unknown",timestamp:Date.now()});}catch(s){if(e)throw new Error(`Resolver ${n.name} failed: ${s instanceof Error?s.message:s}`,{cause:s})}if(t)for(let[n,s]of Object.entries(r))r[n]=s.replace(/\$\{([^}]+)\}/g,(i,u)=>r[u]||"");return b$1(r,a,c),{env:r,provenance:a}}function y(o){return !o||!Array.isArray(o)?[{path:[],message:"Validation failed",code:"unknown_error"}]:o.map(t=>{if(!t||typeof t!="object")return {path:[],message:"Validation failed",code:"unknown_error"};let e=t;return {path:e.path?.map(c=>c.key)||[],message:e.message||"Validation failed",code:e.type}})}async function b(o,t={}){let{resolvers:e=[a()],interpolate:c=false,strict:r=true,references:a$1}=t,{env:n}=await v(e,c,r,a$1);return o.parseAsync(n)}async function w(o,t={}){try{let{resolvers:e=[a()],interpolate:c=!1,strict:r=!0,references:a$1}=t,{env:n}=await v(e,c,r,a$1),s=await o.safeParseAsync(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}function h(o,t={}){let{resolvers:e=[a()],interpolate:c=false,strict:r=true,references:a$1}=t,{env:n}=d(e,c,r,a$1);return o.parse(n)}function S(o,t={}){try{let{resolvers:e=[a()],interpolate:c=!1,strict:r=!0,references:a$1}=t,{env:n}=d(e,c,r,a$1),s=o.safeParse(n);if(s.success)return {success:!0,data:s.output};let i=y(s.issues);return {success:!1,error:i.map(f=>f.message).join(", "),issues:i}}catch(e){return {success:false,error:e instanceof Error?e.message:String(e),issues:[{path:[],message:e instanceof Error?e.message:String(e),code:"resolver_error"}]}}}export{h as resolveSyncValibot,b as resolveValibot,S as safeResolveSyncValibot,w as safeResolveValibot};
|
package/dist/validators.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs');function
|
|
2
|
-
exports.boolean=
|
|
1
|
+
'use strict';var chunkD6WM53FN_cjs=require('./chunk-D6WM53FN.cjs');function u(t){if(!/^postgres(ql)?:\/\/.+/.test(t))return {valid:false,error:"Invalid PostgreSQL URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid PostgreSQL URL"}}}function p(t){if(!/^mysql:\/\/.+/.test(t))return {valid:false,error:"Invalid MySQL URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid MySQL URL"}}}function f(t){return /^mongodb(\+srv)?:\/\/.+/.test(t)?/^mongodb(\+srv)?:\/\/([^@]+@)?[^/]+(\/[^?]*)?(\\?.*)?$/.test(t)?{valid:true}:{valid:false,error:"Invalid MongoDB URL"}:{valid:false,error:"Invalid MongoDB URL"}}function c(t){if(!/^rediss?:\/\/.+/.test(t))return {valid:false,error:"Invalid Redis URL"};try{return new URL(t),{valid:!0}}catch{return {valid:false,error:"Invalid Redis URL"}}}function g(t){try{let n=new URL(t);return ["http:","https:","ws:","wss:","ftp:","ftps:","file:","postgres:","postgresql:","mysql:","mongodb:","redis:","rediss:"].includes(n.protocol)?{valid:!0}:{valid:!1,error:`URL protocol '${n.protocol}' is not allowed`}}catch{return {valid:false,error:"Invalid URL"}}}function m(t){return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t)?t.length>254?{valid:false,error:"Invalid email"}:{valid:true}:{valid:false,error:"Invalid email"}}function w(t){let n=Number(t);return n!==n||n<1||n>65535?{valid:false,error:"Invalid port"}:{valid:true}}function O(t){let n=Number(t);return n!==n?{valid:false,error:"Invalid number"}:{valid:true}}function R(t){let n=t.toLowerCase();return ["true","1","yes","on","false","0","no","off",""].includes(n)?{valid:true}:{valid:false,error:"Invalid boolean"}}function x(t){let n=new Date(t);if(isNaN(n.getTime()))return {valid:false,error:"Invalid date - cannot parse date value"};if(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?)?$/.test(t)){if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let[e,o,a]=t.split("-").map(Number);if(n.getUTCFullYear()!==e||n.getUTCMonth()+1!==o||n.getUTCDate()!==a)return {valid:false,error:"Invalid date value"}}return {valid:true}}return {valid:false,error:"Date must be in ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)"}}function v(t){if(!/^\d+$/.test(t))return {valid:false,error:"Invalid timestamp"};let n=Number(t);return isNaN(n)||n<0?{valid:false,error:"Invalid timestamp"}:n>253402300799?{valid:false,error:"Timestamp too large"}:{valid:true}}function b(t){let n=/^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/,r=/^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+(?:\.\d+)?)ms)?$/,e=t.match(n);if(e){let a=parseFloat(e[1]),s=e[2],l={ms:1,s:1e3,m:60*1e3,h:3600*1e3,d:1440*60*1e3};return {valid:true,value:Math.floor(a*l[s])}}let o=t.match(r);if(o&&o[0]){let a=0;if(o[1]&&(a+=parseFloat(o[1])*60*60*1e3),o[2]&&(a+=parseFloat(o[2])*60*1e3),o[3]&&(a+=parseFloat(o[3])*1e3),o[4]&&(a+=parseFloat(o[4])),a>0)return {valid:true,value:Math.floor(a)}}return {valid:false,error:"Duration must be in format: 5s, 2h, 30m, 1h30m, etc."}}function h(t,n){try{let r=chunkD6WM53FN_cjs.a("fs"),{resolve:e}=chunkD6WM53FN_cjs.a("path"),o=e(process.cwd(),t);return {valid:!0,value:r.readFileSync(o,"utf8").trim()}}catch(r){return {valid:false,error:`Failed to read file${n?` for ${n}`:""}: ${r instanceof Error?r.message:String(r)}`}}}function k(t){let n=(r=>{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid HTTP URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n.__sensitive=true,n}function V(t){let n=(r=>{try{return JSON.parse(r)}catch{throw new Error(`Invalid JSON: "${r}"`)}});return t&&(n.default=t.default,n.optional=t.optional),n}function y(t){let n=((r,e)=>{if(r===""&&!t?.allowEmpty)throw new Error("String cannot be empty");if(t?.min!==void 0&&r.length<t.min)throw new Error(`String too short (min: ${t.min})`);if(t?.max!==void 0&&r.length>t.max)throw new Error(`String too long (max: ${t.max})`);if(t?.pattern&&!new RegExp(t.pattern).test(r)){let o=e?`${e} does not match required pattern`:"String does not match pattern";throw new Error(o)}return r});return t&&(n.default=t.default,n.optional=t.optional),n}function $(t){let n=(r=>{let e=Number(r);if(isNaN(e))throw new Error(`Invalid number: "${r}"`);if(t?.min!==void 0&&e<t.min)throw new Error(`Number too small (min: ${t.min})`);if(t?.max!==void 0&&e>t.max)throw new Error(`Number too large (max: ${t.max})`);return e});return t&&(n.default=t.default,n.optional=t.optional),n}function I(t){let n=(r=>{let e=r.toLowerCase();if(["true","1","yes","on"].includes(e))return true;if(["false","0","no","off",""].includes(e))return false;throw new Error(`Invalid boolean: "${r}"`)});return t&&(n.default=t.default,n.optional=t.optional),n}function T(t){let n=(r=>{try{return new URL(r),r}catch{throw new Error(`Invalid URL: "${r}"`)}});return t&&(n.default=t.default,n.optional=t.optional),n}function E(t){let n=(r=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))throw new Error(`Invalid email: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function L(t){let n=(r=>{let e=Number(r);if(isNaN(e)||e<1||e>65535)throw new Error(`Invalid port: "${r}"`);return e});return t&&(n.default=t.default,n.optional=t.optional),n}function N(t){let n=(r=>{if(!r.startsWith("postgres://")&&!r.startsWith("postgresql://"))throw new Error(`Invalid PostgreSQL URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function U(t){let n=(r=>{if(!r.startsWith("mysql://"))throw new Error(`Invalid MySQL URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function D(t){let n=(r=>{if(!r.startsWith("mongodb://")&&!r.startsWith("mongodb+srv://"))throw new Error(`Invalid MongoDB URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function S(t){let n=(r=>{if(!r.startsWith("redis://")&&!r.startsWith("rediss://"))throw new Error(`Invalid Redis URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function M(t){let n=(r=>{if(!r.startsWith("https://"))throw new Error(`Invalid HTTPS URL: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function P(t){let n=(r=>{let e=t?.separator||",";return r.split(e).map(o=>o.trim()).filter(o=>o.length>0)});return t&&(n.default=t.default,n.optional=t.optional),n}function q(t){let n=(r=>{let e=t?.separator||",";return r.split(e).map(o=>{let a=Number(o.trim());if(isNaN(a))throw new Error(`Invalid number in array: "${o}"`);return a})});return t&&(n.default=t.default,n.optional=t.optional),n}function _(t){let n=(r=>{let e=t?.separator||",",o=r.split(e).map(a=>a.trim()).filter(a=>a.length>0);for(let a of o)try{new URL(a);}catch{throw new Error(`Invalid URL in array: "${a}"`)}return o});return t&&(n.default=t.default,n.optional=t.optional),n}function d(t,n){let r=(e=>{if(!t.includes(e))throw new Error(`Invalid value: "${e}". Allowed values: ${t.join(", ")}`);return e});return n&&(r.default=n.default,r.optional=n.optional),r}function F(t,n){return d(t,n)}function A(t){let n=[...t];return n.__optional=true,n}function W(t){let n=(r=>{let e=r.match(/^(\d+)([smhd])$/);if(!e)throw new Error(`Invalid duration: "${r}". Use format like "5s", "2m", "1h", "1d"`);let[,o,a]=e,l={s:1e3,m:6e4,h:36e5,d:864e5}[a];return Number(o)*l});return t&&(n.default=t.default,n.optional=t.optional),n}function Z(t){let n=(r=>{try{let e=chunkD6WM53FN_cjs.a("fs"),{resolve:o}=chunkD6WM53FN_cjs.a("path"),a=o(process.cwd(),r);return e.readFileSync(a,"utf8").trim()}catch(e){throw new Error(`Failed to read file: ${e instanceof Error?e.message:String(e)}`,{cause:e})}});return t&&(n.default=t.default,n.optional=t.optional,n.secretsDir=t.secretsDir),n.__isFileValidator=true,n}function Y(t){let n=(r=>r);return t&&(n.default=t.default,n.optional=t.optional),n}function z(t,n){let r=t;return n&&(r.default=n.default,r.optional=n.optional),r}function C(t){let n=(r=>{if(!/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/.test(r))throw new Error(`Date must be in ISO 8601 format: "${r}"`);let o=new Date(r);if(isNaN(o.getTime()))throw new Error(`Cannot parse date value: "${r}"`);return r});return t&&(n.default=t.default,n.optional=t.optional),n}function Q(t){let n=(r=>{let e=Number(r);if(isNaN(e)||!Number.isInteger(e))throw new Error(`Invalid timestamp: "${r}"`);if(e<0)throw new Error(`Invalid timestamp: "${r}"`);if(e>253402300799)throw new Error(`Timestamp too large: "${r}"`);return e});return t&&(n.default=t.default,n.optional=t.optional),n}
|
|
2
|
+
exports.boolean=I;exports.custom=z;exports.date=C;exports.duration=W;exports.email=E;exports.enumOf=F;exports.file=Z;exports.http=k;exports.https=M;exports.json=V;exports.mongodb=D;exports.mysql=U;exports.number=$;exports.numberArray=q;exports.oneOf=d;exports.optional=A;exports.port=L;exports.postgres=N;exports.redis=S;exports.secret=Y;exports.string=y;exports.stringArray=P;exports.timestamp=Q;exports.url=T;exports.urlArray=_;exports.validateBoolean=R;exports.validateDate=x;exports.validateDuration=b;exports.validateEmail=m;exports.validateFile=h;exports.validateMongodb=f;exports.validateMysql=p;exports.validateNumber=O;exports.validatePort=w;exports.validatePostgres=u;exports.validateRedis=c;exports.validateTimestamp=v;exports.validateUrl=g;
|
package/dist/validators.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Validator } from './types.cjs';
|
|
1
|
+
import { V as Validator } from './types--RcOnfdl.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Shared validation functions for advanced environment variable types
|
|
@@ -8,11 +8,6 @@ import { Validator } from './types.cjs';
|
|
|
8
8
|
* 'postgres', 'mysql', 'mongodb', 'redis', 'http', 'https', 'url', 'email', 'port', 'json', 'date', 'timestamp'
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
/** Common options shared by all validator factories */
|
|
12
|
-
interface BaseValidatorOpts {
|
|
13
|
-
sensitive?: boolean;
|
|
14
|
-
description?: string;
|
|
15
|
-
}
|
|
16
11
|
/**
|
|
17
12
|
* Result of a validation operation
|
|
18
13
|
*/
|
|
@@ -141,7 +136,7 @@ declare function validateFile(value: string, key?: string): ValidationResult;
|
|
|
141
136
|
declare function http<Opts extends {
|
|
142
137
|
default?: string;
|
|
143
138
|
optional?: boolean;
|
|
144
|
-
}
|
|
139
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
145
140
|
optional: true;
|
|
146
141
|
} ? Validator<string> & {
|
|
147
142
|
optional: true;
|
|
@@ -160,7 +155,7 @@ declare function http<Opts extends {
|
|
|
160
155
|
declare function json<Opts extends {
|
|
161
156
|
default?: unknown;
|
|
162
157
|
optional?: boolean;
|
|
163
|
-
}
|
|
158
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
164
159
|
optional: true;
|
|
165
160
|
} ? Validator<unknown> & {
|
|
166
161
|
optional: true;
|
|
@@ -199,7 +194,7 @@ declare function string<Opts extends {
|
|
|
199
194
|
allowEmpty?: boolean;
|
|
200
195
|
/** Regex pattern to validate against */
|
|
201
196
|
pattern?: string;
|
|
202
|
-
}
|
|
197
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
203
198
|
optional: true;
|
|
204
199
|
} ? Validator<string> & {
|
|
205
200
|
optional: true;
|
|
@@ -234,7 +229,7 @@ declare function number<Opts extends {
|
|
|
234
229
|
min?: number;
|
|
235
230
|
/** Maximum number value */
|
|
236
231
|
max?: number;
|
|
237
|
-
}
|
|
232
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
238
233
|
optional: true;
|
|
239
234
|
} ? Validator<number> & {
|
|
240
235
|
optional: true;
|
|
@@ -266,7 +261,7 @@ declare function boolean<Opts extends {
|
|
|
266
261
|
default?: boolean;
|
|
267
262
|
/** Make the field optional */
|
|
268
263
|
optional?: boolean;
|
|
269
|
-
}
|
|
264
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
270
265
|
optional: true;
|
|
271
266
|
} ? Validator<boolean> & {
|
|
272
267
|
optional: true;
|
|
@@ -297,7 +292,7 @@ declare function url<Opts extends {
|
|
|
297
292
|
default?: string;
|
|
298
293
|
/** Make the field optional */
|
|
299
294
|
optional?: boolean;
|
|
300
|
-
}
|
|
295
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
301
296
|
optional: true;
|
|
302
297
|
} ? Validator<string> & {
|
|
303
298
|
optional: true;
|
|
@@ -328,7 +323,7 @@ declare function email<Opts extends {
|
|
|
328
323
|
default?: string;
|
|
329
324
|
/** Make the field optional */
|
|
330
325
|
optional?: boolean;
|
|
331
|
-
}
|
|
326
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
332
327
|
optional: true;
|
|
333
328
|
} ? Validator<string> & {
|
|
334
329
|
optional: true;
|
|
@@ -359,7 +354,7 @@ declare function port<Opts extends {
|
|
|
359
354
|
default?: number;
|
|
360
355
|
/** Make the field optional */
|
|
361
356
|
optional?: boolean;
|
|
362
|
-
}
|
|
357
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
363
358
|
optional: true;
|
|
364
359
|
} ? Validator<number> & {
|
|
365
360
|
optional: true;
|
|
@@ -391,7 +386,7 @@ declare function postgres<Opts extends {
|
|
|
391
386
|
default?: string;
|
|
392
387
|
/** Make the field optional */
|
|
393
388
|
optional?: boolean;
|
|
394
|
-
}
|
|
389
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
395
390
|
optional: true;
|
|
396
391
|
} ? Validator<string> & {
|
|
397
392
|
optional: true;
|
|
@@ -423,7 +418,7 @@ declare function mysql<Opts extends {
|
|
|
423
418
|
default?: string;
|
|
424
419
|
/** Make the field optional */
|
|
425
420
|
optional?: boolean;
|
|
426
|
-
}
|
|
421
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
427
422
|
optional: true;
|
|
428
423
|
} ? Validator<string> & {
|
|
429
424
|
optional: true;
|
|
@@ -455,7 +450,7 @@ declare function mongodb<Opts extends {
|
|
|
455
450
|
default?: string;
|
|
456
451
|
/** Make the field optional */
|
|
457
452
|
optional?: boolean;
|
|
458
|
-
}
|
|
453
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
459
454
|
optional: true;
|
|
460
455
|
} ? Validator<string> & {
|
|
461
456
|
optional: true;
|
|
@@ -487,7 +482,7 @@ declare function redis<Opts extends {
|
|
|
487
482
|
default?: string;
|
|
488
483
|
/** Make the field optional */
|
|
489
484
|
optional?: boolean;
|
|
490
|
-
}
|
|
485
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
491
486
|
optional: true;
|
|
492
487
|
} ? Validator<string> & {
|
|
493
488
|
optional: true;
|
|
@@ -519,7 +514,7 @@ declare function https<Opts extends {
|
|
|
519
514
|
default?: string;
|
|
520
515
|
/** Make the field optional */
|
|
521
516
|
optional?: boolean;
|
|
522
|
-
}
|
|
517
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
523
518
|
optional: true;
|
|
524
519
|
} ? Validator<string> & {
|
|
525
520
|
optional: true;
|
|
@@ -553,7 +548,7 @@ declare function stringArray<Opts extends {
|
|
|
553
548
|
optional?: boolean;
|
|
554
549
|
/** Separator character (default: ',') */
|
|
555
550
|
separator?: string;
|
|
556
|
-
}
|
|
551
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
557
552
|
optional: true;
|
|
558
553
|
} ? Validator<string[]> & {
|
|
559
554
|
optional: true;
|
|
@@ -587,7 +582,7 @@ declare function numberArray<Opts extends {
|
|
|
587
582
|
optional?: boolean;
|
|
588
583
|
/** Separator character (default: ',') */
|
|
589
584
|
separator?: string;
|
|
590
|
-
}
|
|
585
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
591
586
|
optional: true;
|
|
592
587
|
} ? Validator<number[]> & {
|
|
593
588
|
optional: true;
|
|
@@ -621,7 +616,7 @@ declare function urlArray<Opts extends {
|
|
|
621
616
|
optional?: boolean;
|
|
622
617
|
/** Separator character (default: ',') */
|
|
623
618
|
separator?: string;
|
|
624
|
-
}
|
|
619
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
625
620
|
optional: true;
|
|
626
621
|
} ? Validator<string[]> & {
|
|
627
622
|
optional: true;
|
|
@@ -654,7 +649,7 @@ declare function oneOf<T extends readonly (string | number)[], Opts extends {
|
|
|
654
649
|
default?: T[number];
|
|
655
650
|
/** Make the field optional */
|
|
656
651
|
optional?: boolean;
|
|
657
|
-
}
|
|
652
|
+
} = Record<string, never>>(values: T, opts?: Opts): Opts extends {
|
|
658
653
|
optional: true;
|
|
659
654
|
} ? Validator<T[number]> & {
|
|
660
655
|
optional: true;
|
|
@@ -750,7 +745,7 @@ declare function duration<Opts extends {
|
|
|
750
745
|
default?: number;
|
|
751
746
|
/** Make the field optional */
|
|
752
747
|
optional?: boolean;
|
|
753
|
-
}
|
|
748
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
754
749
|
optional: true;
|
|
755
750
|
} ? Validator<number> & {
|
|
756
751
|
optional: true;
|
|
@@ -784,7 +779,7 @@ declare function file<Opts extends {
|
|
|
784
779
|
optional?: boolean;
|
|
785
780
|
/** Base directory for secrets (Docker/K8s) */
|
|
786
781
|
secretsDir?: string;
|
|
787
|
-
}
|
|
782
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
788
783
|
optional: true;
|
|
789
784
|
} ? Validator<string> & {
|
|
790
785
|
optional: true;
|
|
@@ -818,7 +813,7 @@ declare function secret<Opts extends {
|
|
|
818
813
|
default?: string;
|
|
819
814
|
/** Make the field optional */
|
|
820
815
|
optional?: boolean;
|
|
821
|
-
}
|
|
816
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
822
817
|
optional: true;
|
|
823
818
|
} ? Validator<string> & {
|
|
824
819
|
optional: true;
|
|
@@ -861,7 +856,7 @@ declare function custom<T = unknown, Opts extends {
|
|
|
861
856
|
default?: T;
|
|
862
857
|
/** Make the field optional */
|
|
863
858
|
optional?: boolean;
|
|
864
|
-
}
|
|
859
|
+
} = Record<string, never>>(validator: (value: string) => T, opts?: Opts): Opts extends {
|
|
865
860
|
optional: true;
|
|
866
861
|
} ? Validator<T> & {
|
|
867
862
|
optional: true;
|
|
@@ -893,7 +888,7 @@ declare function date<Opts extends {
|
|
|
893
888
|
default?: string;
|
|
894
889
|
/** Make the field optional */
|
|
895
890
|
optional?: boolean;
|
|
896
|
-
}
|
|
891
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
897
892
|
optional: true;
|
|
898
893
|
} ? Validator<string> & {
|
|
899
894
|
optional: true;
|
|
@@ -925,7 +920,7 @@ declare function timestamp<Opts extends {
|
|
|
925
920
|
default?: number;
|
|
926
921
|
/** Make the field optional */
|
|
927
922
|
optional?: boolean;
|
|
928
|
-
}
|
|
923
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
929
924
|
optional: true;
|
|
930
925
|
} ? Validator<number> & {
|
|
931
926
|
optional: true;
|
|
@@ -934,23 +929,5 @@ declare function timestamp<Opts extends {
|
|
|
934
929
|
optional?: Opts['optional'];
|
|
935
930
|
default?: Opts['default'];
|
|
936
931
|
};
|
|
937
|
-
/**
|
|
938
|
-
* Non-mutating wrapper that marks a validator as sensitive.
|
|
939
|
-
* Creates a new validator that forwards to the original, preserving all metadata.
|
|
940
|
-
*
|
|
941
|
-
* @param validator - The validator to wrap
|
|
942
|
-
* @returns A new validator with sensitive: true in __meta
|
|
943
|
-
*
|
|
944
|
-
* @example
|
|
945
|
-
* ```ts
|
|
946
|
-
* import { string, sensitive } from 'node-env-resolver/validators';
|
|
947
|
-
*
|
|
948
|
-
* const config = resolve({
|
|
949
|
-
* API_KEY: sensitive(string()),
|
|
950
|
-
* DATABASE_URL: sensitive(postgres()),
|
|
951
|
-
* });
|
|
952
|
-
* ```
|
|
953
|
-
*/
|
|
954
|
-
declare function sensitive<T>(validator: Validator<T>): Validator<T>;
|
|
955
932
|
|
|
956
|
-
export { type
|
|
933
|
+
export { type ValidationResult, boolean, custom, date, duration, email, enumOf, file, http, https, json, mongodb, mysql, number, numberArray, oneOf, optional, port, postgres, redis, secret, string, stringArray, timestamp, url, urlArray, validateBoolean, validateDate, validateDuration, validateEmail, validateFile, validateMongodb, validateMysql, validateNumber, validatePort, validatePostgres, validateRedis, validateTimestamp, validateUrl };
|
package/dist/validators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Validator } from './types.js';
|
|
1
|
+
import { V as Validator } from './types--RcOnfdl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Shared validation functions for advanced environment variable types
|
|
@@ -8,11 +8,6 @@ import { Validator } from './types.js';
|
|
|
8
8
|
* 'postgres', 'mysql', 'mongodb', 'redis', 'http', 'https', 'url', 'email', 'port', 'json', 'date', 'timestamp'
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
/** Common options shared by all validator factories */
|
|
12
|
-
interface BaseValidatorOpts {
|
|
13
|
-
sensitive?: boolean;
|
|
14
|
-
description?: string;
|
|
15
|
-
}
|
|
16
11
|
/**
|
|
17
12
|
* Result of a validation operation
|
|
18
13
|
*/
|
|
@@ -141,7 +136,7 @@ declare function validateFile(value: string, key?: string): ValidationResult;
|
|
|
141
136
|
declare function http<Opts extends {
|
|
142
137
|
default?: string;
|
|
143
138
|
optional?: boolean;
|
|
144
|
-
}
|
|
139
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
145
140
|
optional: true;
|
|
146
141
|
} ? Validator<string> & {
|
|
147
142
|
optional: true;
|
|
@@ -160,7 +155,7 @@ declare function http<Opts extends {
|
|
|
160
155
|
declare function json<Opts extends {
|
|
161
156
|
default?: unknown;
|
|
162
157
|
optional?: boolean;
|
|
163
|
-
}
|
|
158
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
164
159
|
optional: true;
|
|
165
160
|
} ? Validator<unknown> & {
|
|
166
161
|
optional: true;
|
|
@@ -199,7 +194,7 @@ declare function string<Opts extends {
|
|
|
199
194
|
allowEmpty?: boolean;
|
|
200
195
|
/** Regex pattern to validate against */
|
|
201
196
|
pattern?: string;
|
|
202
|
-
}
|
|
197
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
203
198
|
optional: true;
|
|
204
199
|
} ? Validator<string> & {
|
|
205
200
|
optional: true;
|
|
@@ -234,7 +229,7 @@ declare function number<Opts extends {
|
|
|
234
229
|
min?: number;
|
|
235
230
|
/** Maximum number value */
|
|
236
231
|
max?: number;
|
|
237
|
-
}
|
|
232
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
238
233
|
optional: true;
|
|
239
234
|
} ? Validator<number> & {
|
|
240
235
|
optional: true;
|
|
@@ -266,7 +261,7 @@ declare function boolean<Opts extends {
|
|
|
266
261
|
default?: boolean;
|
|
267
262
|
/** Make the field optional */
|
|
268
263
|
optional?: boolean;
|
|
269
|
-
}
|
|
264
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
270
265
|
optional: true;
|
|
271
266
|
} ? Validator<boolean> & {
|
|
272
267
|
optional: true;
|
|
@@ -297,7 +292,7 @@ declare function url<Opts extends {
|
|
|
297
292
|
default?: string;
|
|
298
293
|
/** Make the field optional */
|
|
299
294
|
optional?: boolean;
|
|
300
|
-
}
|
|
295
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
301
296
|
optional: true;
|
|
302
297
|
} ? Validator<string> & {
|
|
303
298
|
optional: true;
|
|
@@ -328,7 +323,7 @@ declare function email<Opts extends {
|
|
|
328
323
|
default?: string;
|
|
329
324
|
/** Make the field optional */
|
|
330
325
|
optional?: boolean;
|
|
331
|
-
}
|
|
326
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
332
327
|
optional: true;
|
|
333
328
|
} ? Validator<string> & {
|
|
334
329
|
optional: true;
|
|
@@ -359,7 +354,7 @@ declare function port<Opts extends {
|
|
|
359
354
|
default?: number;
|
|
360
355
|
/** Make the field optional */
|
|
361
356
|
optional?: boolean;
|
|
362
|
-
}
|
|
357
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
363
358
|
optional: true;
|
|
364
359
|
} ? Validator<number> & {
|
|
365
360
|
optional: true;
|
|
@@ -391,7 +386,7 @@ declare function postgres<Opts extends {
|
|
|
391
386
|
default?: string;
|
|
392
387
|
/** Make the field optional */
|
|
393
388
|
optional?: boolean;
|
|
394
|
-
}
|
|
389
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
395
390
|
optional: true;
|
|
396
391
|
} ? Validator<string> & {
|
|
397
392
|
optional: true;
|
|
@@ -423,7 +418,7 @@ declare function mysql<Opts extends {
|
|
|
423
418
|
default?: string;
|
|
424
419
|
/** Make the field optional */
|
|
425
420
|
optional?: boolean;
|
|
426
|
-
}
|
|
421
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
427
422
|
optional: true;
|
|
428
423
|
} ? Validator<string> & {
|
|
429
424
|
optional: true;
|
|
@@ -455,7 +450,7 @@ declare function mongodb<Opts extends {
|
|
|
455
450
|
default?: string;
|
|
456
451
|
/** Make the field optional */
|
|
457
452
|
optional?: boolean;
|
|
458
|
-
}
|
|
453
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
459
454
|
optional: true;
|
|
460
455
|
} ? Validator<string> & {
|
|
461
456
|
optional: true;
|
|
@@ -487,7 +482,7 @@ declare function redis<Opts extends {
|
|
|
487
482
|
default?: string;
|
|
488
483
|
/** Make the field optional */
|
|
489
484
|
optional?: boolean;
|
|
490
|
-
}
|
|
485
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
491
486
|
optional: true;
|
|
492
487
|
} ? Validator<string> & {
|
|
493
488
|
optional: true;
|
|
@@ -519,7 +514,7 @@ declare function https<Opts extends {
|
|
|
519
514
|
default?: string;
|
|
520
515
|
/** Make the field optional */
|
|
521
516
|
optional?: boolean;
|
|
522
|
-
}
|
|
517
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
523
518
|
optional: true;
|
|
524
519
|
} ? Validator<string> & {
|
|
525
520
|
optional: true;
|
|
@@ -553,7 +548,7 @@ declare function stringArray<Opts extends {
|
|
|
553
548
|
optional?: boolean;
|
|
554
549
|
/** Separator character (default: ',') */
|
|
555
550
|
separator?: string;
|
|
556
|
-
}
|
|
551
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
557
552
|
optional: true;
|
|
558
553
|
} ? Validator<string[]> & {
|
|
559
554
|
optional: true;
|
|
@@ -587,7 +582,7 @@ declare function numberArray<Opts extends {
|
|
|
587
582
|
optional?: boolean;
|
|
588
583
|
/** Separator character (default: ',') */
|
|
589
584
|
separator?: string;
|
|
590
|
-
}
|
|
585
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
591
586
|
optional: true;
|
|
592
587
|
} ? Validator<number[]> & {
|
|
593
588
|
optional: true;
|
|
@@ -621,7 +616,7 @@ declare function urlArray<Opts extends {
|
|
|
621
616
|
optional?: boolean;
|
|
622
617
|
/** Separator character (default: ',') */
|
|
623
618
|
separator?: string;
|
|
624
|
-
}
|
|
619
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
625
620
|
optional: true;
|
|
626
621
|
} ? Validator<string[]> & {
|
|
627
622
|
optional: true;
|
|
@@ -654,7 +649,7 @@ declare function oneOf<T extends readonly (string | number)[], Opts extends {
|
|
|
654
649
|
default?: T[number];
|
|
655
650
|
/** Make the field optional */
|
|
656
651
|
optional?: boolean;
|
|
657
|
-
}
|
|
652
|
+
} = Record<string, never>>(values: T, opts?: Opts): Opts extends {
|
|
658
653
|
optional: true;
|
|
659
654
|
} ? Validator<T[number]> & {
|
|
660
655
|
optional: true;
|
|
@@ -750,7 +745,7 @@ declare function duration<Opts extends {
|
|
|
750
745
|
default?: number;
|
|
751
746
|
/** Make the field optional */
|
|
752
747
|
optional?: boolean;
|
|
753
|
-
}
|
|
748
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
754
749
|
optional: true;
|
|
755
750
|
} ? Validator<number> & {
|
|
756
751
|
optional: true;
|
|
@@ -784,7 +779,7 @@ declare function file<Opts extends {
|
|
|
784
779
|
optional?: boolean;
|
|
785
780
|
/** Base directory for secrets (Docker/K8s) */
|
|
786
781
|
secretsDir?: string;
|
|
787
|
-
}
|
|
782
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
788
783
|
optional: true;
|
|
789
784
|
} ? Validator<string> & {
|
|
790
785
|
optional: true;
|
|
@@ -818,7 +813,7 @@ declare function secret<Opts extends {
|
|
|
818
813
|
default?: string;
|
|
819
814
|
/** Make the field optional */
|
|
820
815
|
optional?: boolean;
|
|
821
|
-
}
|
|
816
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
822
817
|
optional: true;
|
|
823
818
|
} ? Validator<string> & {
|
|
824
819
|
optional: true;
|
|
@@ -861,7 +856,7 @@ declare function custom<T = unknown, Opts extends {
|
|
|
861
856
|
default?: T;
|
|
862
857
|
/** Make the field optional */
|
|
863
858
|
optional?: boolean;
|
|
864
|
-
}
|
|
859
|
+
} = Record<string, never>>(validator: (value: string) => T, opts?: Opts): Opts extends {
|
|
865
860
|
optional: true;
|
|
866
861
|
} ? Validator<T> & {
|
|
867
862
|
optional: true;
|
|
@@ -893,7 +888,7 @@ declare function date<Opts extends {
|
|
|
893
888
|
default?: string;
|
|
894
889
|
/** Make the field optional */
|
|
895
890
|
optional?: boolean;
|
|
896
|
-
}
|
|
891
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
897
892
|
optional: true;
|
|
898
893
|
} ? Validator<string> & {
|
|
899
894
|
optional: true;
|
|
@@ -925,7 +920,7 @@ declare function timestamp<Opts extends {
|
|
|
925
920
|
default?: number;
|
|
926
921
|
/** Make the field optional */
|
|
927
922
|
optional?: boolean;
|
|
928
|
-
}
|
|
923
|
+
} = Record<string, never>>(opts?: Opts): Opts extends {
|
|
929
924
|
optional: true;
|
|
930
925
|
} ? Validator<number> & {
|
|
931
926
|
optional: true;
|
|
@@ -934,23 +929,5 @@ declare function timestamp<Opts extends {
|
|
|
934
929
|
optional?: Opts['optional'];
|
|
935
930
|
default?: Opts['default'];
|
|
936
931
|
};
|
|
937
|
-
/**
|
|
938
|
-
* Non-mutating wrapper that marks a validator as sensitive.
|
|
939
|
-
* Creates a new validator that forwards to the original, preserving all metadata.
|
|
940
|
-
*
|
|
941
|
-
* @param validator - The validator to wrap
|
|
942
|
-
* @returns A new validator with sensitive: true in __meta
|
|
943
|
-
*
|
|
944
|
-
* @example
|
|
945
|
-
* ```ts
|
|
946
|
-
* import { string, sensitive } from 'node-env-resolver/validators';
|
|
947
|
-
*
|
|
948
|
-
* const config = resolve({
|
|
949
|
-
* API_KEY: sensitive(string()),
|
|
950
|
-
* DATABASE_URL: sensitive(postgres()),
|
|
951
|
-
* });
|
|
952
|
-
* ```
|
|
953
|
-
*/
|
|
954
|
-
declare function sensitive<T>(validator: Validator<T>): Validator<T>;
|
|
955
932
|
|
|
956
|
-
export { type
|
|
933
|
+
export { type ValidationResult, boolean, custom, date, duration, email, enumOf, file, http, https, json, mongodb, mysql, number, numberArray, oneOf, optional, port, postgres, redis, secret, string, stringArray, timestamp, url, urlArray, validateBoolean, validateDate, validateDuration, validateEmail, validateFile, validateMongodb, validateMysql, validateNumber, validatePort, validatePostgres, validateRedis, validateTimestamp, validateUrl };
|