@tantainnovative/ndpr-toolkit
Version:
Nigeria Data Protection Toolkit — enterprise-grade compliance components for the Nigeria Data Protection Act (NDPA) 2023
1 lines • 1.57 kB
JavaScript
function i(e){let t=[];if((!e.consents||Object.keys(e.consents).length===0)&&t.push({field:"consents",code:"consents_required",message:"Consent settings must include at least one consent option"}),e.timestamp?(typeof e.timestamp!="number"||isNaN(e.timestamp))&&t.push({field:"timestamp",code:"timestamp_invalid",message:"Consent timestamp must be a valid number"}):t.push({field:"timestamp",code:"timestamp_required",message:"Consent timestamp is required"}),e.version||t.push({field:"version",code:"version_required",message:"Consent version is required"}),e.method||t.push({field:"method",code:"method_required",message:"Consent collection method is required"}),e.hasInteracted===void 0&&t.push({field:"hasInteracted",code:"has_interacted_required",message:"User interaction status is required"}),e.timestamp){let r=new Date;r.setMonth(r.getMonth()-13);let s=r.getTime();e.timestamp<s&&t.push({field:"timestamp",code:"consent_stale",message:"Consent is older than 13 months and should be refreshed"});}return t.length>0?{valid:false,errors:t}:{valid:true,errors:[],data:e}}function n(e){let t=[];return (!e||e.length===0)&&t.push({field:"options",code:"options_required",message:"At least one consent option is required"}),e==null||e.forEach((r,s)=>{(!r.purpose||r.purpose.trim()==="")&&t.push({field:`options[${s}].purpose`,code:"purpose_required",message:`Consent option "${r.id}" is missing a purpose. NDPA Section 26 requires consent to be specific to a stated purpose.`});}),t.length>0?{valid:false,errors:t}:{valid:true,errors:[],data:e}}export{i as a,n as b};