UNPKG

validlyjs

Version:

A high-performance Laravel-inspired validation library for TypeScript/JavaScript

10 lines (9 loc) 476 B
import{a as e}from"./index-Ci9AjmGp.js" let r=null const a={name:"array.each",validate:async(a,t,n,i)=>{if(!a||"object"!=typeof a||"number"!=typeof a.length)return!1 const o=t[0] if(!o)return!0 const s=(r||(r=new e),r),f=a.length,l={field:"",data:i,parameters:[],index:0} for(let e=0;f>e;e++)if(l.field=`${n}[${e}]`,l.index=e,!(await s.validateValue(a[e],o,l)).passed)return!1 return!0},message:"One or more items in {field} are invalid.",async:!0} export{a as arrayEachRule}