(target, coIndex)
| 3956 | // coIndex is only used where target is a complex object that is part of an array of complex objects |
| 3957 | // in which case ctIndex is the index of the target within the array. |
| 3958 | function validateTarget(target, coIndex) { |
| 3959 | var ok = true; |
| 3960 | var stype = target.entityType || target.complexType; |
| 3961 | var aspect = target.entityAspect || target.complexAspect; |
| 3962 | var entityAspect = target.entityAspect || target.complexAspect.getEntityAspect(); |
| 3963 | var context = { entity: entityAspect.entity }; |
| 3964 | if (coIndex !== undefined) { |
| 3965 | context.index = coIndex; |
| 3966 | } |
| 3967 | |
| 3968 | stype.getProperties().forEach(function (p) { |
| 3969 | var value = target.getProperty(p.name); |
| 3970 | var validators = p.getAllValidators(); |
| 3971 | if (validators.length > 0) { |
| 3972 | context.property = p; |
| 3973 | context.propertyName = aspect.getPropertyPath(p.name); |
| 3974 | ok = entityAspect._validateProperty(value, context) && ok; |
| 3975 | } |
| 3976 | if (p.isComplexProperty) { |
| 3977 | if (p.isScalar) { |
| 3978 | ok = validateTarget(value) && ok; |
| 3979 | } else { |
| 3980 | ok = value.reduce(function (pv, cv, ix) { |
| 3981 | return validateTarget(cv, ix) && pv; |
| 3982 | }, ok); |
| 3983 | } |
| 3984 | } |
| 3985 | }); |
| 3986 | |
| 3987 | |
| 3988 | // then target level |
| 3989 | stype.getAllValidators().forEach(function (validator) { |
| 3990 | ok = validate(entityAspect, validator, target) && ok; |
| 3991 | }); |
| 3992 | return ok; |
| 3993 | } |
| 3994 | |
| 3995 | |
| 3996 | /** |
no test coverage detected