in src/types/MArrayType.ts [8:29]
function arrayValidator(assembly:Assembly, schema:MFieldSchemaAnonymity, value:any, path:string): MValidationResult {
// 校验一下数组元素
if(schema.arrayMember){
for(let i = 0; i < value.length; i++){
let item = value[i];
const r = assembly.validate(schema.arrayMember, item, path + "[" + i + "]");
if(r){
return {message: "", path};; // 子元素校验没过,数组上不用展示信息
}
}
}
const min = schema.min ?? (schema.required ? 1: 0);
const max = schema.max ?? Number.MAX_VALUE;
if(value.length < min){
return {message: "最少" + min + "项", path};;
}
if(value.length > max) {
return {message: "最多" + schema.max + "项", path};
}
return undefined;
}