How multiple item checks work for forms or objects
masterTo validate multiple items (like form fields) at once, call assert with two objects.
Parameters:
- An object where keys are field names and values are the items to validate.
- An object where keys are field names and values are arrays of rule strings.
Return Value:
Returns a report object containing a top-level valid boolean and a fields object containing sub-reports for each item. Each sub-report follows the same structure as a single item check.
const items = {
name : 5,
email : 'test@example.com',
password : 'abcdefgh',
};
const rules = {
name : ['required', 'string'],
email : ['required', 'email'],
password : ['required'],
};
const report = Iodine.assert(items, rules);
// report.valid will be false because 'name' is not a string
// report.fields.name will contain the error details