private static Constraint CreateConstraint(ConstraintsAndMappers.Item.Entry entry, Func<Type, IMapValidationConstraint> createMapper) { var mapper = createMapper(entry.RuleGeneratorType); if (mapper == null) { return null; } var rule = Reflection.InvokeCreateFromMethod(entry.RuleGeneratorType, mapper, entry.PropertyValidator); return new Constraint(mapper.Name, rule); }
public static ConstraintsResult GetConstraints( ConstraintsAndMappers self, Func<Type, IMapValidationConstraint> createMapper) { var parameters = self.Parameters.Select(p => new Parameter( p.Field.ToCamelCase(), p.Constraints .Select(c => CreateConstraint(c, createMapper)) .Where(c => c != null) .ToList())) .ToList(); return new ConstraintsResult(parameters); }