@sot1986/appsync-precognition 0.5.10 → 0.5.11
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { a as I18n, c as ValidationErrors, i as FullRule, n as CustomFullRule, o as NestedKeyOf, s as Rule, t as Ctx } from "./types-VxM9TxGV.js";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
|
-
declare function validate<T
|
|
4
|
+
declare function validate<T>(obj: Readonly<Partial<T>>, checks: Partial<{ [key in NestedKeyOf<T>]: Array<FullRule | CustomFullRule | Omit<Rule<T>, "value">> }>, options?: {
|
|
5
5
|
trim?: boolean;
|
|
6
6
|
allowEmptyString?: boolean;
|
|
7
7
|
errors?: Partial<ValidationErrors>;
|
|
8
8
|
attributes?: Partial<Record<`:${NestedKeyOf<T>}`, string>>;
|
|
9
9
|
}): T;
|
|
10
|
-
declare function precognitiveValidation<T
|
|
10
|
+
declare function precognitiveValidation<T>(ctx: Ctx<Partial<T>>, checks: Partial<{ [key in NestedKeyOf<T>]: Array<FullRule | CustomFullRule | Omit<Rule, "value">> }>, options?: {
|
|
11
11
|
trim?: boolean;
|
|
12
12
|
allowEmptyString?: boolean;
|
|
13
13
|
skipTo?: "END" | "NEXT";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAagB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAagB,iBACT,SAAS,QAAQ,aACd,kBACE,YAAY,KAAK,MACrB,WACA,iBACA,KAAK,KAAK,yBALX;;EADP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,UAAA,MAsLW,CAtLX,GAsLe,CAtLf,CAsLiB,GAtLjB,CAAA,EAAA,EAEd,gBAAA,MAAA,CAAA,CAAA,GAAA,EAuLI,GAvLJ,CAuLQ,OAvLR,CAuLgB,CAvLhB,CAAA,CAAA,EAAA,MAAA,CAAA,EAwLQ,OAxLR,CAAA,EAAA,GAAA,IAAA,OAyLc,GAzLd,GAAA;EAiGH,KAAgB,EAAA,OAyFA,GAAA,CAAI,KAzFJ,GAAA;IACG,MAAA,EAyFP,IAzFO,CAyFF,CAzFE,EAAA,MAAA,CAAA;EAAR,CAAA;CAAJ;AAEiB,iBAkGR,eAlGQ,CAAZ,UAAA,UAAA,MAmGgB,CAnGhB,GAmGoB,CAnGpB,CAmGsB,GAnGtB,CAAA,EAAA,EACJ,gBAAA,MAAA,CACA,CAAA,GAAA,EAoGD,GApGC,CAoGG,OApGH,CAoGW,CApGX,CAAA,CAAA,EAAA,MAAA,CAAA,EAqGG,OArGH,CAAA,EAAA,QAAA,GAAA,IAAA,OAsGiB,GAtGjB,GAAA;EACK,KAAA,EAAA,OAsGG,GAAA,CAAI,KAtGP,GAAA;IAAL,MAAA,EAuGI,IAvGJ,CAuGS,CAvGT,EAAA,MAAA,CAAA;EAHqB,CAAA;CADnB"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{baseErrors,cleanString,date,datetime,email,getHeader,getNestedValue,integer,isArray,numeric,parseErrorMessage,phone,setNestedValue,time,ulid,url,uuid}from"./utils.js";import{runtime,util}from"@aws-appsync/utils";function parse(c,A){const[P,...F]=typeof A===`string`?[A,void 0]:isArray(A)?[A[0],...A.slice(1)]:typeof A.rule===`string`?[A.rule,void 0]:[A.rule[0],...A.rule.slice(1)];switch(P){case`required`:return requiredRule(c);case`nullable`:return nullableRule(c);case`sometimes`:return sometimesRule(c);case`min`:case`bigger`:return betweenRule(c,F[0],void 0,P===`bigger`);case`max`:case`lower`:return betweenRule(c,void 0,F[0],P===`lower`);case`between`:case`within`:return betweenRule(c,F[0],F[1],P===`within`);case`regex`:return regexRule(c,...F);case`in`:return inRule(c,...F);case`notIn`:return notInRule(c,...F);case`before`:case`beforeOrEqual`:return beforeRule(c,F[0],P===`before`);case`after`:case`afterOrEqual`:return afterRule(c,F[0],P===`after`);case`email`:return regexRule({...c,msg:c.msg??c.errors.email},email);case`phone`:return regexRule({...c,msg:c.msg??c.errors.phone},phone);case`url`:return regexRule({...c,msg:c.msg??c.errors.url},url);case`uuid`:return regexRule({...c,msg:c.msg??c.errors.uuid},uuid);case`ulid`:return regexRule({...c,msg:c.msg??c.errors.ulid},ulid);case`integer`:return regexRule({...c,msg:c.msg??c.errors.integer},integer);case`date`:return regexRule({...c,msg:c.msg??c.errors.date},date);case`time`:return regexRule({...c,msg:c.msg??c.errors.time},time);case`datetime`:return regexRule({...c,msg:c.msg??c.errors.datetime},datetime);case`numeric`:return regexRule({...c,msg:c.msg??c.errors.numeric},numeric);default:return typeRule(c,P)}}function betweenRule({value:c,msg:A,errors:j},M=-Infinity,N=Infinity,P=false){const[F,I]=[N===Infinity,M===-Infinity];const R={check:false,msg:A??F?P?j.biggerNumber:j.minNumber:I?P?j.lowerNumber:j.maxNumber:P?j.withinNumber:j.betweenNumber,value:c,params:{":min":`${M}`,":max":`${N}`}};if(typeof c===`number`)R.check=P?c>M&&c<N:c>=M&&c<=N;if(typeof c===`string`){R.check=c.length>=M&&c.length<=N;R.msg=A??F?j.minString:I?j.maxString:j.betweenString}if(isArray(c)){R.check=c.length>=M&&c.length<=N;R.msg=A??F?j.minArray:I?j.maxArray:j.betweenArray}return R}function regexRule({value:c,msg:A,errors:j},...M){const N={check:false,msg:A??(M.length===1?j.regex:j.regex_patterns),value:c,params:M.length===1?{":pattern":M[0]}:{":patterns":M.join(`, `)}};if(typeof c===`string`)N.check=M.some(A=>util.matches(A,c));if(typeof c===`number`)N.check=M.some(A=>util.matches(A,`${c}`));return N}function inRule({value:c,msg:A,errors:j},...M){return{check:M.includes(c),msg:A??j.in,value:c,params:{":in":M.join(`, `)}}}function notInRule({value:c,msg:A,errors:j},...M){return{check:!M.includes(c),msg:A??j.notIn,value:c,params:{":notIn":M.join(`, `)}}}function requiredRule({value:c,msg:A,errors:j}){const M={check:true,msg:A??j.required,value:c,skipNext:true};if(typeof c===`string`)M.check=c.length>0;if(isArray(c))M.check=c.length>0;if(typeof c===`number`)M.check=true;if(typeof c===`boolean`)M.check=true;if(typeof c===`object`&&!M.value)M.check=false;if(typeof c===`undefined`)M.check=false;M.skipNext=!M.check;return M}function nullableRule({value:c,msg:A,errors:j}){return{check:true,msg:A??j.nullable,value:c,skipNext:typeof c===`undefined`||c===null}}function sometimesRule({value:c,msg:A,errors:j}){const M={check:true,msg:A??j.sometimes,value:c};if(typeof c===`undefined`){M.skipNext=true;return M}if(typeof c===`object`&&!M.value){M.check=false;M.skipNext=true;return M}return requiredRule({value:c,msg:A,errors:j})}function typeRule({value:c,msg:A,errors:j},M){const N={check:false,msg:A??j.type,value:c,params:{":type":M}};switch(M){case`array`:N.check=isArray(c);break;case`object`:N.check=typeof c===`object`&&!!c&&!isArray(c)&&Object.keys(c).length>0;break;case`boolean`:N.check=typeof c===`boolean`;break;case`number`:N.check=typeof c===`number`;break;default:N.check=typeof c===`string`}return N}function beforeRule({value:c,msg:A,errors:j},M,N=false){const P={check:false,msg:A??j.before,value:c,params:N?{":before":M}:{":beforeOrEqual":M}};const F=util.time.parseISO8601ToEpochMilliSeconds(M);const I=typeof c===`string`?util.time.parseISO8601ToEpochMilliSeconds(c):c;if(typeof I===`number`)P.check=N?I<F:I<=F;return P}function afterRule({value:c,msg:A,errors:j},M,N=false){const P={check:false,msg:A??N?j.after:j.afterOrEqual,value:c,params:N?{":after":M}:{":afterOrEqual":M}};const F=util.time.parseISO8601ToEpochMilliSeconds(M);const I=typeof c===`string`?util.time.parseISO8601ToEpochMilliSeconds(c):c;if(typeof I===`number`)P.check=N?I>F:I>=F;return P}function isRule(c){return typeof c===`object`&&!!c&&Object.hasOwn(c,`check`)}function isCustomFullRule(c){return typeof c===`object`&&!!c&&Object.hasOwn(c,`rule`)}function validate(j,M,N){let P={};const I={...baseErrors,...N?.errors};sanitizeNestedArray(j,M);if(N?.attributes)sanitizeNestedArray(j,N.attributes);const L=JSON.parse(JSON.stringify(j));Object.keys(M).forEach(c=>{let j=getNestedValue(L,c);if(typeof j===`string`){j=cleanString(j,N);setNestedValue(L,c,j)}let R=false;M[c]?.forEach(A=>{if(R)return;const M=isRule(A)?{...A,value:j,msg:A.msg??I.invalid}:isCustomFullRule(A)?parse({value:j,msg:A.msg,errors:I},A.rule):parse({value:j,errors:I},A);R=!!M.skipNext||!M.check;if(M.check)return;if(P.msg)util.appendError(P.msg,P.errorType,P.data,P.errorInfo);M.params=M.params??{};if(util.matches(`:attr`,M.msg))M.params[`:attr`]=N?.attributes?.[`:${c}`]??formatAttributeName(c);P={msg:parseErrorMessage(M.msg,M.params),errorType:`ValidationError`,data:null,errorInfo:{path:c,value:j}}})});if(!P.msg)return L;util.error(P.msg,P.errorType,P.data,P.errorInfo)}function sanitizeNestedArray(c,A){let j=[];Object.keys(A).forEach(c=>{const A=c.split(`.`).filter(c=>c===`*`);if(A.length>j.length)j=[...A]});j.forEach(()=>{Object.keys(A).forEach(j=>{const M=j.split(`.`);const N=M.indexOf(`*`,1);if(N<1)return;const P=M.slice(0,N).join(`.`);const I=getNestedValue(c,P.startsWith(`:`)?P.slice(1):P);if(!isArray(I))return;I.forEach((c,P)=>{const F=[...M];F[N]=`${P}`;A[F.join(`.`)]=A[j]});delete A[j]})})}function precognitiveValidation(c,A,j){const{errors:M,attributes:N}=isLocalized(c)?{errors:{...c.stash.__i18n.errors,...j?.errors},attributes:{...c.stash.__i18n.attributes,...j?.attributes}}:{errors:j?.errors,attributes:j?.attributes};if(getHeader(`precognition`,c)!==`true`)return c.stash.__validated=validate(c.args,A,{...j,errors:M,attributes:N});const F=getHeader(`Precognition-Validate-Only`,c)?.split(`,`).map(c=>c.trim());util.http.addResponseHeader(`Precognition`,`true`);if(!F){c.stash.__validated=validate(c.args,A,{...j,errors:M,attributes:N});util.http.addResponseHeader(`Precognition-Success`,`true`);runtime.earlyReturn(null)}util.http.addResponseHeader(`Precognition-Validate-Only`,F.join(`,`));const I={};F.forEach(c=>{I[c]=A[c]});c.stash.__validated=validate(c.args,I,{...j,errors:M,attributes:N});util.http.addResponseHeader(`Precognition-Success`,`true`);runtime.earlyReturn(null,{skipTo:j?.skipTo??`END`})}function formatAttributeName(c){return c.split(`.`).reduce((c,A)=>{if(util.matches(`^\\d+$`,A))return c;let j=``;A.split(``).forEach((c,A)=>{if(A!==0&&util.matches(`[A-Z]`,c))j+=` `;j+=c.toLowerCase()});return c?`${c} ${j}`:j},``)}function assertValidated(c){if(Object.hasOwn(c.stash,`__validated`))return;util.error(`Context arguments have not been validated`)}function isLocalized(c,A){if(Object.hasOwn(c.stash,`__i18n`)&&typeof c.stash?.__i18n.locale===`string`)return A?c.stash.__i18n.locale===A:true;return false}function assertLocalized(c,A){if(isLocalized(c,A))return;util.error(`Context arguements have not been localized`)}export{assertLocalized,assertValidated,formatAttributeName,isLocalized,precognitiveValidation,validate};
|
|
1
|
+
import{baseErrors,cleanString,date,datetime,email,getHeader,getNestedValue,integer,isArray,numeric,parseErrorMessage,phone,setNestedValue,time,ulid,url,uuid}from"./utils.js";import{runtime,util}from"@aws-appsync/utils";function parse(c,A){const[P,...F]=typeof A===`string`?[A,void 0]:isArray(A)?[A[0],...A.slice(1)]:typeof A.rule===`string`?[A.rule,void 0]:[A.rule[0],...A.rule.slice(1)];switch(P){case`required`:return requiredRule(c);case`nullable`:return nullableRule(c);case`sometimes`:return sometimesRule(c);case`min`:case`bigger`:return betweenRule(c,F[0],void 0,P===`bigger`);case`max`:case`lower`:return betweenRule(c,void 0,F[0],P===`lower`);case`between`:case`within`:return betweenRule(c,F[0],F[1],P===`within`);case`regex`:return regexRule(c,...F);case`in`:return inRule(c,...F);case`notIn`:return notInRule(c,...F);case`before`:case`beforeOrEqual`:return beforeRule(c,F[0],P===`before`);case`after`:case`afterOrEqual`:return afterRule(c,F[0],P===`after`);case`email`:return regexRule({...c,msg:c.msg??c.errors.email},email);case`phone`:return regexRule({...c,msg:c.msg??c.errors.phone},phone);case`url`:return regexRule({...c,msg:c.msg??c.errors.url},url);case`uuid`:return regexRule({...c,msg:c.msg??c.errors.uuid},uuid);case`ulid`:return regexRule({...c,msg:c.msg??c.errors.ulid},ulid);case`integer`:return regexRule({...c,msg:c.msg??c.errors.integer},integer);case`date`:return regexRule({...c,msg:c.msg??c.errors.date},date);case`time`:return regexRule({...c,msg:c.msg??c.errors.time},time);case`datetime`:return regexRule({...c,msg:c.msg??c.errors.datetime},datetime);case`numeric`:return regexRule({...c,msg:c.msg??c.errors.numeric},numeric);default:return typeRule(c,P)}}function betweenRule({value:c,msg:A,errors:j},M=-Infinity,N=Infinity,P=false){const[F,I]=[N===Infinity,M===-Infinity];const R={check:false,msg:A??F?P?j.biggerNumber:j.minNumber:I?P?j.lowerNumber:j.maxNumber:P?j.withinNumber:j.betweenNumber,value:c,params:{":min":`${M}`,":max":`${N}`}};if(typeof c===`number`)R.check=P?c>M&&c<N:c>=M&&c<=N;if(typeof c===`string`){R.check=c.length>=M&&c.length<=N;R.msg=A??F?j.minString:I?j.maxString:j.betweenString}if(isArray(c)){R.check=c.length>=M&&c.length<=N;R.msg=A??F?j.minArray:I?j.maxArray:j.betweenArray}return R}function regexRule({value:c,msg:A,errors:j},...M){const N={check:false,msg:A??(M.length===1?j.regex:j.regex_patterns),value:c,params:M.length===1?{":pattern":M[0]}:{":patterns":M.join(`, `)}};if(typeof c===`string`)N.check=M.some(A=>util.matches(A,c));if(typeof c===`number`)N.check=M.some(A=>util.matches(A,`${c}`));return N}function inRule({value:c,msg:A,errors:j},...M){return{check:M.includes(c),msg:A??j.in,value:c,params:{":in":M.join(`, `)}}}function notInRule({value:c,msg:A,errors:j},...M){return{check:!M.includes(c),msg:A??j.notIn,value:c,params:{":notIn":M.join(`, `)}}}function requiredRule({value:c,msg:A,errors:j}){const M={check:true,msg:A??j.required,value:c,skipNext:true};if(typeof c===`string`)M.check=c.length>0;if(isArray(c))M.check=c.length>0;if(typeof c===`number`)M.check=true;if(typeof c===`boolean`)M.check=true;if(typeof c===`object`&&!M.value)M.check=false;if(typeof c===`undefined`)M.check=false;M.skipNext=!M.check;return M}function nullableRule({value:c,msg:A,errors:j}){return{check:true,msg:A??j.nullable,value:c,skipNext:typeof c===`undefined`||c===null}}function sometimesRule({value:c,msg:A,errors:j}){const M={check:true,msg:A??j.sometimes,value:c};if(typeof c===`undefined`){M.skipNext=true;return M}if(typeof c===`object`&&!M.value){M.check=false;M.skipNext=true;return M}return requiredRule({value:c,msg:A,errors:j})}function typeRule({value:c,msg:A,errors:j},M){const N={check:false,msg:A??j.type,value:c,params:{":type":M}};switch(M){case`array`:N.check=isArray(c);break;case`object`:N.check=typeof c===`object`&&!!c&&!isArray(c)&&Object.keys(c).length>0;break;case`boolean`:N.check=typeof c===`boolean`;break;case`number`:N.check=typeof c===`number`;break;default:N.check=typeof c===`string`}return N}function beforeRule({value:c,msg:A,errors:j},M,N=false){const P={check:false,msg:A??j.before,value:c,params:N?{":before":M}:{":beforeOrEqual":M}};const F=util.time.parseISO8601ToEpochMilliSeconds(M);const I=typeof c===`string`?util.time.parseISO8601ToEpochMilliSeconds(c):c;if(typeof I===`number`)P.check=N?I<F:I<=F;return P}function afterRule({value:c,msg:A,errors:j},M,N=false){const P={check:false,msg:A??N?j.after:j.afterOrEqual,value:c,params:N?{":after":M}:{":afterOrEqual":M}};const F=util.time.parseISO8601ToEpochMilliSeconds(M);const I=typeof c===`string`?util.time.parseISO8601ToEpochMilliSeconds(c):c;if(typeof I===`number`)P.check=N?I>F:I>=F;return P}function isRule(c){return typeof c===`object`&&!!c&&Object.hasOwn(c,`check`)}function isCustomFullRule(c){return typeof c===`object`&&!!c&&Object.hasOwn(c,`rule`)}function validate(j,M,N){let P={};const I={...baseErrors,...N?.errors};if(typeof j!==`object`)util.error(`Object expected`);sanitizeNestedArray(j,M);if(N?.attributes)sanitizeNestedArray(j,N.attributes);const L=JSON.parse(JSON.stringify(j));Object.keys(M).forEach(c=>{let j=getNestedValue(L,c);if(typeof j===`string`){j=cleanString(j,N);setNestedValue(L,c,j)}let R=false;M[c]?.forEach(A=>{if(R)return;const M=isRule(A)?{...A,value:j,msg:A.msg??I.invalid}:isCustomFullRule(A)?parse({value:j,msg:A.msg,errors:I},A.rule):parse({value:j,errors:I},A);R=!!M.skipNext||!M.check;if(M.check)return;if(P.msg)util.appendError(P.msg,P.errorType,P.data,P.errorInfo);M.params=M.params??{};if(util.matches(`:attr`,M.msg))M.params[`:attr`]=N?.attributes?.[`:${c}`]??formatAttributeName(c);P={msg:parseErrorMessage(M.msg,M.params),errorType:`ValidationError`,data:null,errorInfo:{path:c,value:j}}})});if(!P.msg)return L;util.error(P.msg,P.errorType,P.data,P.errorInfo)}function sanitizeNestedArray(c,A){let j=[];Object.keys(A).forEach(c=>{const A=c.split(`.`).filter(c=>c===`*`);if(A.length>j.length)j=[...A]});j.forEach(()=>{Object.keys(A).forEach(j=>{const M=j.split(`.`);const N=M.indexOf(`*`,1);if(N<1)return;const P=M.slice(0,N).join(`.`);const I=getNestedValue(c,P.startsWith(`:`)?P.slice(1):P);if(!isArray(I))return;I.forEach((c,P)=>{const F=[...M];F[N]=`${P}`;A[F.join(`.`)]=A[j]});delete A[j]})})}function precognitiveValidation(c,A,j){const{errors:M,attributes:N}=isLocalized(c)?{errors:{...c.stash.__i18n.errors,...j?.errors},attributes:{...c.stash.__i18n.attributes,...j?.attributes}}:{errors:j?.errors,attributes:j?.attributes};if(getHeader(`precognition`,c)!==`true`)return c.stash.__validated=validate(c.args,A,{...j,errors:M,attributes:N});const F=getHeader(`Precognition-Validate-Only`,c)?.split(`,`).map(c=>c.trim());util.http.addResponseHeader(`Precognition`,`true`);if(!F){c.stash.__validated=validate(c.args,A,{...j,errors:M,attributes:N});util.http.addResponseHeader(`Precognition-Success`,`true`);runtime.earlyReturn(null)}util.http.addResponseHeader(`Precognition-Validate-Only`,F.join(`,`));const I={};F.forEach(c=>{I[c]=A[c]});c.stash.__validated=validate(c.args,I,{...j,errors:M,attributes:N});util.http.addResponseHeader(`Precognition-Success`,`true`);runtime.earlyReturn(null,{skipTo:j?.skipTo??`END`})}function formatAttributeName(c){return c.split(`.`).reduce((c,A)=>{if(util.matches(`^\\d+$`,A))return c;let j=``;A.split(``).forEach((c,A)=>{if(A!==0&&util.matches(`[A-Z]`,c))j+=` `;j+=c.toLowerCase()});return c?`${c} ${j}`:j},``)}function assertValidated(c){if(Object.hasOwn(c.stash,`__validated`))return;util.error(`Context arguments have not been validated`)}function isLocalized(c,A){if(Object.hasOwn(c.stash,`__i18n`)&&typeof c.stash?.__i18n.locale===`string`)return A?c.stash.__i18n.locale===A:true;return false}function assertLocalized(c,A){if(isLocalized(c,A))return;util.error(`Context arguements have not been localized`)}export{assertLocalized,assertValidated,formatAttributeName,isLocalized,precognitiveValidation,validate};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["result: ParsedRule<T>","error: { msg?: string, errorType?: string, data?: any, errorInfo?: any }","errors: ValidationErrors","validated: T","skip: boolean","rules.parse","maxKeys: string[]"],"sources":["../src/rules.ts","../src/index.ts"],"sourcesContent":["import type { CustomFullRule, FullRule, ParsedRule, ParseOptions } from './types'\nimport { util } from '@aws-appsync/utils'\nimport { date, datetime, email, integer, isArray, numeric, phone, time, ulid, url, uuid } from './utils'\n\nexport function parse<T>(\n opt: ParseOptions<T>,\n rule: FullRule | CustomFullRule,\n): ParsedRule<T> {\n const [n, ...p] = typeof rule === 'string'\n ? [rule, undefined]\n : isArray(rule)\n ? [rule[0], ...rule.slice(1)]\n : typeof rule.rule === 'string'\n ? [rule.rule, undefined]\n : [rule.rule[0], ...rule.rule.slice(1)]\n\n switch (n) {\n case 'required':\n return requiredRule(opt)\n case 'nullable':\n return nullableRule(opt)\n case 'sometimes':\n return sometimesRule(opt)\n case 'min':\n case 'bigger':\n return betweenRule(opt, (p[0]! as number), undefined, n === 'bigger')\n case 'max':\n case 'lower':\n return betweenRule(opt, undefined, (p[0] as number), n === 'lower')\n case 'between':\n case 'within':\n return betweenRule(opt, (p[0] as number), p[1] as number, n === 'within')\n case 'regex':\n return regexRule(opt, ...p as string[])\n case 'in':\n return inRule(opt, ...p)\n case 'notIn':\n return notInRule(opt, ...p)\n case 'before':\n case 'beforeOrEqual':\n return beforeRule(opt, p[0] as string, n === 'before')\n case 'after':\n case 'afterOrEqual':\n return afterRule(opt, p[0] as string, n === 'after')\n case 'email':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.email }, email)\n case 'phone':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.phone }, phone)\n case 'url':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.url }, url)\n case 'uuid':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.uuid }, uuid)\n case 'ulid':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.ulid }, ulid)\n case 'integer':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.integer }, integer)\n case 'date':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.date }, date)\n case 'time':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.time }, time)\n case 'datetime':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.datetime }, datetime)\n case 'numeric':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.numeric }, numeric)\n default:\n return typeRule(opt, n)\n }\n}\n\nfunction betweenRule<T>(\n { value, msg, errors }: ParseOptions<T>,\n minV: number = -Infinity,\n maxV: number = Infinity,\n strict = false,\n): ParsedRule<T> {\n const [min, max] = [maxV === Infinity, minV === -Infinity]\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? min\n ? strict\n ? errors.biggerNumber\n : errors.minNumber\n : max\n ? strict\n ? errors.lowerNumber\n : errors.maxNumber\n : strict\n ? errors.withinNumber\n : errors.betweenNumber,\n value,\n params: {\n ':min': `${minV}`,\n ':max': `${maxV}`,\n },\n }\n if (typeof value === 'number')\n result.check = strict ? value > minV && value < maxV : value >= minV && value <= maxV\n\n if (typeof value === 'string') {\n result.check = value.length >= minV && value.length <= maxV\n result.msg = msg ?? min\n ? errors.minString\n : max\n ? errors.maxString\n : errors.betweenString\n }\n if (isArray(value)) {\n result.check = value.length >= minV && value.length <= maxV\n result.msg = msg ?? min\n ? errors.minArray\n : max\n ? errors.maxArray\n : errors.betweenArray\n }\n return result\n}\n\nfunction regexRule<T>({ value, msg, errors }: ParseOptions<T>, ...p: string[]): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? (p.length === 1 ? errors.regex : errors.regex_patterns),\n value,\n params: p.length === 1\n ? { ':pattern': p[0]! }\n : { ':patterns': p.join(', ') },\n }\n if (typeof value === 'string')\n result.check = p.some(pt => util.matches(pt, value))\n\n if (typeof value === 'number')\n result.check = p.some(pt => util.matches(pt, `${value}`))\n\n return result\n}\n\nfunction inRule<T>({ value, msg, errors }: ParseOptions<T>, ...p: unknown[]): ParsedRule<T> {\n return {\n check: p.includes(value),\n msg: msg ?? errors.in,\n value,\n params: { ':in': p.join(', ') },\n }\n}\n\nfunction notInRule<T>({ value, msg, errors }: ParseOptions<T>, ...p: unknown[]): ParsedRule<T> {\n return {\n check: !p.includes(value),\n msg: msg ?? errors.notIn,\n value,\n params: { ':notIn': p.join(', ') },\n }\n}\n\nexport function requiredRule<T>({ value, msg, errors }: ParseOptions<T>): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: true,\n msg: msg ?? errors.required,\n value,\n skipNext: true,\n }\n if (typeof value === 'string')\n result.check = value.length > 0\n if (isArray(value))\n result.check = value.length > 0\n if (typeof value === 'number')\n result.check = true\n if (typeof value === 'boolean')\n result.check = true\n if (typeof value === 'object' && !result.value) {\n result.check = false\n }\n if (typeof value === 'undefined')\n result.check = false\n result.skipNext = !result.check\n return result\n}\n\nfunction nullableRule<T>({ value, msg, errors }: ParseOptions<T>): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: true,\n msg: msg ?? errors.nullable,\n value,\n skipNext: typeof value === 'undefined' || value === null,\n }\n return result\n}\n\nfunction sometimesRule<T>({ value, msg, errors }: ParseOptions<T>): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: true,\n msg: msg ?? errors.sometimes,\n value,\n }\n if (typeof value === 'undefined') {\n result.skipNext = true\n return result\n }\n if (typeof value === 'object' && !result.value) {\n result.check = false\n result.skipNext = true\n return result\n }\n return requiredRule({ value, msg, errors })\n}\n\nfunction typeRule<T>({ value, msg, errors }: ParseOptions<T>, type: 'boolean' | 'object' | 'array' | 'number' | 'string'): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? errors.type,\n value,\n params: { ':type': type },\n }\n switch (type) {\n case 'array':\n result.check = isArray(value)\n break\n case 'object':\n result.check = typeof value === 'object' && !!value && !isArray(value) && Object.keys(value).length > 0\n break\n case 'boolean':\n result.check = typeof value === 'boolean'\n break\n case 'number':\n result.check = typeof value === 'number'\n break\n default:\n result.check = typeof value === 'string'\n }\n return result\n}\n\nfunction beforeRule<T>({ value, msg, errors }: ParseOptions<T>, start: string, strict = false): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? errors.before,\n value,\n params: strict\n ? { ':before': start }\n : { ':beforeOrEqual': start },\n }\n const startValue = util.time.parseISO8601ToEpochMilliSeconds(start)\n const numDate = typeof value === 'string'\n ? util.time.parseISO8601ToEpochMilliSeconds(value)\n : value\n if (typeof numDate === 'number')\n result.check = strict ? numDate < startValue : numDate <= startValue\n return result\n}\n\nfunction afterRule<T>({ value, msg, errors }: ParseOptions<T>, p: string, strict = false): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? strict ? errors.after : errors.afterOrEqual,\n value,\n params: strict\n ? { ':after': p }\n : { ':afterOrEqual': p },\n }\n const e = util.time.parseISO8601ToEpochMilliSeconds(p)\n const numDate = typeof value === 'string'\n ? util.time.parseISO8601ToEpochMilliSeconds(value)\n : value\n if (typeof numDate === 'number')\n result.check = strict ? numDate > e : numDate >= e\n\n return result\n}\n","import type { Ctx, CustomFullRule, FullRule, I18n, NestedKeyOf, Rule, ValidationErrors } from './types'\nimport { runtime, util } from '@aws-appsync/utils'\nimport * as rules from './rules'\nimport { baseErrors, cleanString, getHeader, getNestedValue, isArray, parseErrorMessage, setNestedValue } from './utils'\n\nfunction isRule(rule: FullRule | CustomFullRule | Omit<Rule, 'value'>): rule is Omit<Rule, 'value'> {\n return typeof rule === 'object' && !!rule && Object.hasOwn(rule, 'check')\n}\n\nfunction isCustomFullRule(rule: FullRule | CustomFullRule | Omit<Rule, 'value'>): rule is CustomFullRule {\n return typeof rule === 'object' && !!rule && Object.hasOwn(rule, 'rule')\n}\n\nexport function validate<T extends Exclude<object, null>>(\n obj: Readonly<Partial<T>>,\n checks: Partial<{\n [key in NestedKeyOf<T>]: Array<\n | FullRule\n | CustomFullRule\n | Omit<Rule<T>, 'value'>\n > }>,\n options?: {\n trim?: boolean\n allowEmptyString?: boolean\n errors?: Partial<ValidationErrors>\n attributes?: Partial<Record<`:${NestedKeyOf<T>}`, string>>\n },\n): T {\n let error: { msg?: string, errorType?: string, data?: any, errorInfo?: any } = {}\n const errors: ValidationErrors = { ...baseErrors, ...options?.errors }\n\n sanitizeNestedArray(obj, checks)\n if (options?.attributes)\n sanitizeNestedArray(obj, options.attributes)\n\n const validated: T = JSON.parse(JSON.stringify(obj))\n Object.keys(checks).forEach((path) => {\n let value = getNestedValue(validated, path as NestedKeyOf<T>)\n if (typeof value === 'string') {\n value = cleanString(value, options)\n setNestedValue(validated, path as NestedKeyOf<T>, value)\n }\n\n let skip: boolean = false\n checks[path as keyof typeof checks]?.forEach((rule) => {\n if (skip)\n return\n\n const result = isRule(rule)\n ? { ...rule, value, msg: rule.msg ?? errors.invalid }\n : isCustomFullRule(rule)\n ? rules.parse({ value, msg: rule.msg, errors }, rule.rule)\n : rules.parse({ value, errors }, rule)\n\n skip = !!result.skipNext || !result.check\n\n if (result.check)\n return\n\n if (error.msg)\n util.appendError(error.msg, error.errorType, error.data, error.errorInfo)\n\n result.params = result.params ?? {}\n\n if (util.matches(':attr', result.msg))\n result.params[':attr'] = options?.attributes?.[`:${path as NestedKeyOf<T>}`] ?? formatAttributeName(path as NestedKeyOf<T>)\n\n error = {\n msg: parseErrorMessage(result.msg, result.params),\n errorType: 'ValidationError',\n data: null,\n errorInfo: { path, value },\n }\n })\n })\n\n if (!error.msg) {\n return validated as T\n }\n\n util.error(error.msg, error.errorType, error.data, error.errorInfo)\n}\n\nfunction sanitizeNestedArray(\n obj: object,\n nested: object,\n): void {\n let maxKeys: string[] = []\n Object.keys(nested).forEach((path: string) => {\n const currentKeys = path.split('.').filter(k => k === '*')\n if (currentKeys.length > maxKeys.length) {\n maxKeys = [...currentKeys]\n }\n })\n\n maxKeys.forEach(() => {\n Object.keys(nested).forEach((path) => {\n const keys = path.split('.')\n const wildcardIdx = keys.indexOf('*', 1)\n\n if (wildcardIdx < 1)\n return\n\n const parentPath = keys.slice(0, wildcardIdx).join('.')\n const parentValue = getNestedValue(\n obj,\n parentPath.startsWith(':') ? parentPath.slice(1) : parentPath,\n )\n\n if (!isArray(parentValue))\n return\n\n parentValue.forEach((_, i) => {\n const idxPath = [...keys]\n idxPath[wildcardIdx] = `${i}`\n nested[idxPath.join('.') as keyof typeof nested] = nested[path as keyof typeof nested]\n })\n delete nested[path as keyof typeof nested]\n })\n })\n}\n\nexport function precognitiveValidation<T extends Exclude<object, null>>(\n ctx: Ctx<Partial<T>>,\n checks: Partial<{\n [key in NestedKeyOf<T>]: Array<\n | FullRule\n | CustomFullRule\n | Omit<Rule, 'value'>\n > }>,\n options?: {\n trim?: boolean\n allowEmptyString?: boolean\n skipTo?: 'END' | 'NEXT'\n errors?: Partial<ValidationErrors>\n attributes?: Partial<Record<`:${NestedKeyOf<T>}`, string>>\n },\n): T {\n const { errors, attributes } = (isLocalized<T, string>(ctx)\n ? {\n errors: {\n ...ctx.stash.__i18n.errors,\n ...options?.errors,\n },\n attributes: {\n ...ctx.stash.__i18n.attributes,\n ...options?.attributes,\n },\n }\n : { errors: options?.errors, attributes: options?.attributes }) as {\n errors: Partial<ValidationErrors>\n attributes: Partial<Record<`:${NestedKeyOf<T>}`, string>>\n }\n if (getHeader('precognition', ctx) !== 'true')\n return ctx.stash.__validated = validate<T>(ctx.args, checks, { ...options, errors, attributes })\n\n const validationKeys = getHeader('Precognition-Validate-Only', ctx)?.split(',').map(key => key.trim())\n util.http.addResponseHeader('Precognition', 'true')\n\n if (!validationKeys) {\n ctx.stash.__validated = validate(ctx.args, checks, { ...options, errors, attributes })\n util.http.addResponseHeader('Precognition-Success', 'true')\n runtime.earlyReturn(null)\n }\n\n util.http.addResponseHeader('Precognition-Validate-Only', validationKeys.join(','))\n const precognitionChecks = {} as Partial<typeof checks>\n validationKeys.forEach((key) => {\n precognitionChecks[key as keyof typeof precognitionChecks] = checks[key as keyof typeof checks]\n })\n\n ctx.stash.__validated = validate(ctx.args, precognitionChecks, { ...options, errors, attributes })\n util.http.addResponseHeader('Precognition-Success', 'true')\n runtime.earlyReturn(null, { skipTo: options?.skipTo ?? 'END' })\n}\n\nexport function formatAttributeName(path: string): string {\n return path.split('.').reduce((acc, part) => {\n if (util.matches('^\\\\d+$', part)) {\n return acc\n }\n let words = ''\n part.split('').forEach((char, idx) => {\n if (idx !== 0 && util.matches('[A-Z]', char)) {\n words += ' '\n }\n words += char.toLowerCase()\n })\n return acc ? `${acc} ${words}` : words\n }, '')\n}\n\nexport function assertValidated<\n T extends { [key in keyof T]: T[key] },\n>(\n ctx: Ctx<Partial<T>>,\n): asserts ctx is typeof ctx & {\n stash: { __validated: T }\n} {\n if (Object.hasOwn(ctx.stash, '__validated'))\n return\n util.error('Context arguments have not been validated')\n}\n\nexport function isLocalized<\n T extends { [key in keyof T]: T[key] },\n TLocale extends string,\n>(\n ctx: Ctx<Partial<T>>,\n locale?: TLocale,\n): ctx is typeof ctx & {\n stash: typeof ctx.stash & {\n __i18n: I18n<T, string>\n }\n} {\n if (Object.hasOwn(ctx.stash, '__i18n') && typeof ctx.stash?.__i18n.locale === 'string') {\n return locale\n ? ctx.stash.__i18n.locale === locale\n : true\n }\n return false\n}\n\nexport function assertLocalized<\n T extends { [key in keyof T]: T[key] },\n TLocale extends string,\n>(\n ctx: Ctx<Partial<T>>,\n locale?: TLocale,\n): asserts ctx is typeof ctx & {\n stash: typeof ctx.stash & {\n __i18n: I18n<T, string>\n }\n} {\n if (isLocalized<T, TLocale>(ctx, locale))\n return\n util.error('Context arguements have not been localized')\n}\n\nexport type { CustomFullRule, FullRule, I18n, Rule, ValidationErrors } from './types'\n"],"mappings":"2NAIA,SAAgB,MACd,EACA,EACe,CACf,KAAM,CAAC,EAAG,GAAG,GAAK,OAAO,IAAS,SAC9B,CAAC,EAAM,IAAA,GAAU,CACjB,QAAQ,EAAK,CACX,CAAC,EAAK,GAAI,GAAG,EAAK,MAAM,EAAE,CAAC,CAC3B,OAAO,EAAK,OAAS,SACnB,CAAC,EAAK,KAAM,IAAA,GAAU,CACtB,CAAC,EAAK,KAAK,GAAI,GAAG,EAAK,KAAK,MAAM,EAAE,CAAC,CAE7C,OAAQ,EAAR,CACE,IAAK,WACH,OAAO,aAAa,EAAI,CAC1B,IAAK,WACH,OAAO,aAAa,EAAI,CAC1B,IAAK,YACH,OAAO,cAAc,EAAI,CAC3B,IAAK,MACL,IAAK,SACH,OAAO,YAAY,EAAM,EAAE,GAAgB,IAAA,GAAW,IAAM,SAAS,CACvE,IAAK,MACL,IAAK,QACH,OAAO,YAAY,EAAK,IAAA,GAAY,EAAE,GAAe,IAAM,QAAQ,CACrE,IAAK,UACL,IAAK,SACH,OAAO,YAAY,EAAM,EAAE,GAAe,EAAE,GAAc,IAAM,SAAS,CAC3E,IAAK,QACH,OAAO,UAAU,E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,GAAG,IAAU,GAChC,GAAG,CAGR,SAAgB,gBAGd,EAGA,CACA,GAAI,OAAO,OAAO,EAAI,MAAO,cAAc,CACzC,OACF,KAAK,MAAM,4CAA4C,CAGzD,SAAgB,YAId,EACA,EAKA,CACA,GAAI,OAAO,OAAO,EAAI,MAAO,SAAS,EAAI,OAAO,EAAI,OAAO,OAAO,SAAW,SAC5E,OAAO,EACH,EAAI,MAAM,OAAO,SAAW,EAC5B,KAEN,MAAO,OAGT,SAAgB,gBAId,EACA,EAKA,CACA,GAAI,YAAwB,EAAK,EAAO,CACtC,OACF,KAAK,MAAM,6CAA6C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["result: ParsedRule<T>","error: { msg?: string, errorType?: string, data?: any, errorInfo?: any }","errors: ValidationErrors","validated: T & object","skip: boolean","rules.parse","maxKeys: string[]"],"sources":["../src/rules.ts","../src/index.ts"],"sourcesContent":["import type { CustomFullRule, FullRule, ParsedRule, ParseOptions } from './types'\nimport { util } from '@aws-appsync/utils'\nimport { date, datetime, email, integer, isArray, numeric, phone, time, ulid, url, uuid } from './utils'\n\nexport function parse<T>(\n opt: ParseOptions<T>,\n rule: FullRule | CustomFullRule,\n): ParsedRule<T> {\n const [n, ...p] = typeof rule === 'string'\n ? [rule, undefined]\n : isArray(rule)\n ? [rule[0], ...rule.slice(1)]\n : typeof rule.rule === 'string'\n ? [rule.rule, undefined]\n : [rule.rule[0], ...rule.rule.slice(1)]\n\n switch (n) {\n case 'required':\n return requiredRule(opt)\n case 'nullable':\n return nullableRule(opt)\n case 'sometimes':\n return sometimesRule(opt)\n case 'min':\n case 'bigger':\n return betweenRule(opt, (p[0]! as number), undefined, n === 'bigger')\n case 'max':\n case 'lower':\n return betweenRule(opt, undefined, (p[0] as number), n === 'lower')\n case 'between':\n case 'within':\n return betweenRule(opt, (p[0] as number), p[1] as number, n === 'within')\n case 'regex':\n return regexRule(opt, ...p as string[])\n case 'in':\n return inRule(opt, ...p)\n case 'notIn':\n return notInRule(opt, ...p)\n case 'before':\n case 'beforeOrEqual':\n return beforeRule(opt, p[0] as string, n === 'before')\n case 'after':\n case 'afterOrEqual':\n return afterRule(opt, p[0] as string, n === 'after')\n case 'email':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.email }, email)\n case 'phone':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.phone }, phone)\n case 'url':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.url }, url)\n case 'uuid':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.uuid }, uuid)\n case 'ulid':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.ulid }, ulid)\n case 'integer':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.integer }, integer)\n case 'date':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.date }, date)\n case 'time':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.time }, time)\n case 'datetime':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.datetime }, datetime)\n case 'numeric':\n return regexRule({ ...opt, msg: opt.msg ?? opt.errors.numeric }, numeric)\n default:\n return typeRule(opt, n)\n }\n}\n\nfunction betweenRule<T>(\n { value, msg, errors }: ParseOptions<T>,\n minV: number = -Infinity,\n maxV: number = Infinity,\n strict = false,\n): ParsedRule<T> {\n const [min, max] = [maxV === Infinity, minV === -Infinity]\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? min\n ? strict\n ? errors.biggerNumber\n : errors.minNumber\n : max\n ? strict\n ? errors.lowerNumber\n : errors.maxNumber\n : strict\n ? errors.withinNumber\n : errors.betweenNumber,\n value,\n params: {\n ':min': `${minV}`,\n ':max': `${maxV}`,\n },\n }\n if (typeof value === 'number')\n result.check = strict ? value > minV && value < maxV : value >= minV && value <= maxV\n\n if (typeof value === 'string') {\n result.check = value.length >= minV && value.length <= maxV\n result.msg = msg ?? min\n ? errors.minString\n : max\n ? errors.maxString\n : errors.betweenString\n }\n if (isArray(value)) {\n result.check = value.length >= minV && value.length <= maxV\n result.msg = msg ?? min\n ? errors.minArray\n : max\n ? errors.maxArray\n : errors.betweenArray\n }\n return result\n}\n\nfunction regexRule<T>({ value, msg, errors }: ParseOptions<T>, ...p: string[]): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? (p.length === 1 ? errors.regex : errors.regex_patterns),\n value,\n params: p.length === 1\n ? { ':pattern': p[0]! }\n : { ':patterns': p.join(', ') },\n }\n if (typeof value === 'string')\n result.check = p.some(pt => util.matches(pt, value))\n\n if (typeof value === 'number')\n result.check = p.some(pt => util.matches(pt, `${value}`))\n\n return result\n}\n\nfunction inRule<T>({ value, msg, errors }: ParseOptions<T>, ...p: unknown[]): ParsedRule<T> {\n return {\n check: p.includes(value),\n msg: msg ?? errors.in,\n value,\n params: { ':in': p.join(', ') },\n }\n}\n\nfunction notInRule<T>({ value, msg, errors }: ParseOptions<T>, ...p: unknown[]): ParsedRule<T> {\n return {\n check: !p.includes(value),\n msg: msg ?? errors.notIn,\n value,\n params: { ':notIn': p.join(', ') },\n }\n}\n\nexport function requiredRule<T>({ value, msg, errors }: ParseOptions<T>): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: true,\n msg: msg ?? errors.required,\n value,\n skipNext: true,\n }\n if (typeof value === 'string')\n result.check = value.length > 0\n if (isArray(value))\n result.check = value.length > 0\n if (typeof value === 'number')\n result.check = true\n if (typeof value === 'boolean')\n result.check = true\n if (typeof value === 'object' && !result.value) {\n result.check = false\n }\n if (typeof value === 'undefined')\n result.check = false\n result.skipNext = !result.check\n return result\n}\n\nfunction nullableRule<T>({ value, msg, errors }: ParseOptions<T>): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: true,\n msg: msg ?? errors.nullable,\n value,\n skipNext: typeof value === 'undefined' || value === null,\n }\n return result\n}\n\nfunction sometimesRule<T>({ value, msg, errors }: ParseOptions<T>): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: true,\n msg: msg ?? errors.sometimes,\n value,\n }\n if (typeof value === 'undefined') {\n result.skipNext = true\n return result\n }\n if (typeof value === 'object' && !result.value) {\n result.check = false\n result.skipNext = true\n return result\n }\n return requiredRule({ value, msg, errors })\n}\n\nfunction typeRule<T>({ value, msg, errors }: ParseOptions<T>, type: 'boolean' | 'object' | 'array' | 'number' | 'string'): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? errors.type,\n value,\n params: { ':type': type },\n }\n switch (type) {\n case 'array':\n result.check = isArray(value)\n break\n case 'object':\n result.check = typeof value === 'object' && !!value && !isArray(value) && Object.keys(value).length > 0\n break\n case 'boolean':\n result.check = typeof value === 'boolean'\n break\n case 'number':\n result.check = typeof value === 'number'\n break\n default:\n result.check = typeof value === 'string'\n }\n return result\n}\n\nfunction beforeRule<T>({ value, msg, errors }: ParseOptions<T>, start: string, strict = false): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? errors.before,\n value,\n params: strict\n ? { ':before': start }\n : { ':beforeOrEqual': start },\n }\n const startValue = util.time.parseISO8601ToEpochMilliSeconds(start)\n const numDate = typeof value === 'string'\n ? util.time.parseISO8601ToEpochMilliSeconds(value)\n : value\n if (typeof numDate === 'number')\n result.check = strict ? numDate < startValue : numDate <= startValue\n return result\n}\n\nfunction afterRule<T>({ value, msg, errors }: ParseOptions<T>, p: string, strict = false): ParsedRule<T> {\n const result: ParsedRule<T> = {\n check: false,\n msg: msg ?? strict ? errors.after : errors.afterOrEqual,\n value,\n params: strict\n ? { ':after': p }\n : { ':afterOrEqual': p },\n }\n const e = util.time.parseISO8601ToEpochMilliSeconds(p)\n const numDate = typeof value === 'string'\n ? util.time.parseISO8601ToEpochMilliSeconds(value)\n : value\n if (typeof numDate === 'number')\n result.check = strict ? numDate > e : numDate >= e\n\n return result\n}\n","import type { Ctx, CustomFullRule, FullRule, I18n, NestedKeyOf, Rule, ValidationErrors } from './types'\nimport { runtime, util } from '@aws-appsync/utils'\nimport * as rules from './rules'\nimport { baseErrors, cleanString, getHeader, getNestedValue, isArray, parseErrorMessage, setNestedValue } from './utils'\n\nfunction isRule(rule: FullRule | CustomFullRule | Omit<Rule, 'value'>): rule is Omit<Rule, 'value'> {\n return typeof rule === 'object' && !!rule && Object.hasOwn(rule, 'check')\n}\n\nfunction isCustomFullRule(rule: FullRule | CustomFullRule | Omit<Rule, 'value'>): rule is CustomFullRule {\n return typeof rule === 'object' && !!rule && Object.hasOwn(rule, 'rule')\n}\n\nexport function validate<T>(\n obj: Readonly<Partial<T>>,\n checks: Partial<{\n [key in NestedKeyOf<T>]: Array<\n | FullRule\n | CustomFullRule\n | Omit<Rule<T>, 'value'>\n > }>,\n options?: {\n trim?: boolean\n allowEmptyString?: boolean\n errors?: Partial<ValidationErrors>\n attributes?: Partial<Record<`:${NestedKeyOf<T>}`, string>>\n },\n): T {\n let error: { msg?: string, errorType?: string, data?: any, errorInfo?: any } = {}\n const errors: ValidationErrors = { ...baseErrors, ...options?.errors }\n if (typeof obj !== 'object')\n util.error('Object expected')\n\n sanitizeNestedArray(obj, checks)\n if (options?.attributes)\n sanitizeNestedArray(obj, options.attributes)\n\n const validated: T & object = JSON.parse(JSON.stringify(obj))\n Object.keys(checks).forEach((path) => {\n let value = getNestedValue(validated, path)\n if (typeof value === 'string') {\n value = cleanString(value, options)\n setNestedValue(validated, path as NestedKeyOf<T>, value)\n }\n\n let skip: boolean = false\n checks[path as keyof typeof checks]?.forEach((rule) => {\n if (skip)\n return\n\n const result = isRule(rule)\n ? { ...rule, value, msg: rule.msg ?? errors.invalid }\n : isCustomFullRule(rule)\n ? rules.parse({ value, msg: rule.msg, errors }, rule.rule)\n : rules.parse({ value, errors }, rule)\n\n skip = !!result.skipNext || !result.check\n\n if (result.check)\n return\n\n if (error.msg)\n util.appendError(error.msg, error.errorType, error.data, error.errorInfo)\n\n result.params = result.params ?? {}\n\n if (util.matches(':attr', result.msg))\n result.params[':attr'] = options?.attributes?.[`:${path as NestedKeyOf<T>}`] ?? formatAttributeName(path as NestedKeyOf<T>)\n\n error = {\n msg: parseErrorMessage(result.msg, result.params),\n errorType: 'ValidationError',\n data: null,\n errorInfo: { path, value },\n }\n })\n })\n\n if (!error.msg) {\n return validated as T\n }\n\n util.error(error.msg, error.errorType, error.data, error.errorInfo)\n}\n\nfunction sanitizeNestedArray(\n obj: object,\n nested: object,\n): void {\n let maxKeys: string[] = []\n Object.keys(nested).forEach((path: string) => {\n const currentKeys = path.split('.').filter(k => k === '*')\n if (currentKeys.length > maxKeys.length) {\n maxKeys = [...currentKeys]\n }\n })\n\n maxKeys.forEach(() => {\n Object.keys(nested).forEach((path) => {\n const keys = path.split('.')\n const wildcardIdx = keys.indexOf('*', 1)\n\n if (wildcardIdx < 1)\n return\n\n const parentPath = keys.slice(0, wildcardIdx).join('.')\n const parentValue = getNestedValue(\n obj,\n parentPath.startsWith(':') ? parentPath.slice(1) : parentPath,\n )\n\n if (!isArray(parentValue))\n return\n\n parentValue.forEach((_, i) => {\n const idxPath = [...keys]\n idxPath[wildcardIdx] = `${i}`\n nested[idxPath.join('.') as keyof typeof nested] = nested[path as keyof typeof nested]\n })\n delete nested[path as keyof typeof nested]\n })\n })\n}\n\nexport function precognitiveValidation<T>(\n ctx: Ctx<Partial<T>>,\n checks: Partial<{\n [key in NestedKeyOf<T>]: Array<\n | FullRule\n | CustomFullRule\n | Omit<Rule, 'value'>\n > }>,\n options?: {\n trim?: boolean\n allowEmptyString?: boolean\n skipTo?: 'END' | 'NEXT'\n errors?: Partial<ValidationErrors>\n attributes?: Partial<Record<`:${NestedKeyOf<T>}`, string>>\n },\n): T {\n const { errors, attributes } = (isLocalized<T, string>(ctx)\n ? {\n errors: {\n ...ctx.stash.__i18n.errors,\n ...options?.errors,\n },\n attributes: {\n ...ctx.stash.__i18n.attributes,\n ...options?.attributes,\n },\n }\n : { errors: options?.errors, attributes: options?.attributes }) as {\n errors: Partial<ValidationErrors>\n attributes: Partial<Record<`:${NestedKeyOf<T>}`, string>>\n }\n if (getHeader('precognition', ctx) !== 'true')\n return ctx.stash.__validated = validate<T>(ctx.args, checks, { ...options, errors, attributes })\n\n const validationKeys = getHeader('Precognition-Validate-Only', ctx)?.split(',').map(key => key.trim())\n util.http.addResponseHeader('Precognition', 'true')\n\n if (!validationKeys) {\n ctx.stash.__validated = validate(ctx.args, checks, { ...options, errors, attributes })\n util.http.addResponseHeader('Precognition-Success', 'true')\n runtime.earlyReturn(null)\n }\n\n util.http.addResponseHeader('Precognition-Validate-Only', validationKeys.join(','))\n const precognitionChecks = {} as Partial<typeof checks>\n validationKeys.forEach((key) => {\n precognitionChecks[key as keyof typeof precognitionChecks] = checks[key as keyof typeof checks]\n })\n\n ctx.stash.__validated = validate(ctx.args, precognitionChecks, { ...options, errors, attributes })\n util.http.addResponseHeader('Precognition-Success', 'true')\n runtime.earlyReturn(null, { skipTo: options?.skipTo ?? 'END' })\n}\n\nexport function formatAttributeName(path: string): string {\n return path.split('.').reduce((acc, part) => {\n if (util.matches('^\\\\d+$', part)) {\n return acc\n }\n let words = ''\n part.split('').forEach((char, idx) => {\n if (idx !== 0 && util.matches('[A-Z]', char)) {\n words += ' '\n }\n words += char.toLowerCase()\n })\n return acc ? `${acc} ${words}` : words\n }, '')\n}\n\nexport function assertValidated<\n T extends { [key in keyof T]: T[key] },\n>(\n ctx: Ctx<Partial<T>>,\n): asserts ctx is typeof ctx & {\n stash: { __validated: T }\n} {\n if (Object.hasOwn(ctx.stash, '__validated'))\n return\n util.error('Context arguments have not been validated')\n}\n\nexport function isLocalized<\n T extends { [key in keyof T]: T[key] },\n TLocale extends string,\n>(\n ctx: Ctx<Partial<T>>,\n locale?: TLocale,\n): ctx is typeof ctx & {\n stash: typeof ctx.stash & {\n __i18n: I18n<T, string>\n }\n} {\n if (Object.hasOwn(ctx.stash, '__i18n') && typeof ctx.stash?.__i18n.locale === 'string') {\n return locale\n ? ctx.stash.__i18n.locale === locale\n : true\n }\n return false\n}\n\nexport function assertLocalized<\n T extends { [key in keyof T]: T[key] },\n TLocale extends string,\n>(\n ctx: Ctx<Partial<T>>,\n locale?: TLocale,\n): asserts ctx is typeof ctx & {\n stash: typeof ctx.stash & {\n __i18n: I18n<T, string>\n }\n} {\n if (isLocalized<T, TLocale>(ctx, locale))\n return\n util.error('Context arguements have not been localized')\n}\n\nexport type { CustomFullRule, FullRule, I18n, Rule, ValidationErrors } from './types'\n"],"mappings":"2NAIA,SAAgB,MACd,EACA,EACe,CACf,KAAM,CAAC,EAAG,GAAG,GAAK,OAAO,IAAS,SAC9B,CAAC,EAAM,IAAA,GAAU,CACjB,QAAQ,EAAK,CACX,CAAC,EAAK,GAAI,GAAG,EAAK,MAAM,EAAE,CAAC,CAC3B,OAAO,EAAK,OAAS,SACnB,CAAC,EAAK,KAAM,IAAA,GAAU,CACtB,CAAC,EAAK,KAAK,GAAI,GAAG,EAAK,KAAK,MAAM,EAAE,CAAC,CAE7C,OAAQ,EAAR,CACE,IAAK,WACH,OAAO,aAAa,EAAI,CAC1B,IAAK,WACH,OAAO,aAAa,EAAI,CAC1B,IAAK,YACH,OAAO,cAAc,EAAI,CAC3B,IAAK,MACL,IAAK,SACH,OAAO,YAAY,EAAM,EAAE,GAAgB,IAAA,GAAW,IAAM,SAAS,CACvE,IAAK,MACL,IAAK,QACH,OAAO,YAAY,EAAK,IAAA,GAAY,EAAE,GAAe,IAAM,QAAQ,CACrE,IAAK,UACL,IAAK,SACH,OAAO,YAAY,EAAM,EAAE,GAAe,EAAE,GAAc,IAAM,SAAS,CAC3E,IAAK,QACH,OAAO,UAAU,EAAK,GAAG,EAAc,CACzC,IAAK,KACH,OAAO,OAAO,EAAK,GAAG,EAAE,CAC1B,IAAK,QACH,OAAO,UAAU,EAAK,GAAG,EAAE,CAC7B,IAAK,SACL,IAAK,gBACH,OAAO,WAAW,EAAK,EAAE,GAAc,IAAM,SAAS,CACxD,IAAK,QACL,IAAK,eACH,OAAO,UAAU,EAAK,EAAE,GAAc,IAAM,QAAQ,CACtD,IAAK,QACH,OAAO,UAAU,CAAE,GAAG,EAA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