public CandidateValidation(ValidationInfo validation, ValidationFieldSource extraFieldSource)
 {
     Validation = validation;
     Fields     = new List <ValidationFieldSource> {
         extraFieldSource
     };
 }
Exemple #2
0
        private static string DescribeTypeMismatch(CandidateValidation candidate, ValidationFieldSource source)
        {
            var targetFieldRef      = source.TargetField.TargetFieldInfo.Field.Describe();
            var targetType          = source.Target.GetType().Name;
            var targetFieldType     = source.TargetField.TargetFieldInfo.Type.Name;
            var validationDesc      = $"{candidate.Validation.ContainingType.Name}.{candidate.Validation.Method.Name}";
            var validationParamRef  = source.Field.Name;
            var validationParamType = source.Field.Type.Name;
            var errorMessage        =
                $"{targetFieldRef} on {targetType} has type {targetFieldType} which is not compatible with validation {validationDesc}'s {validationParamRef} which requires {validationParamType}";

            return(errorMessage);
        }
 private IEnumerable <ValidationFieldSource> Enumerate(ValidationFieldSource extraFieldSource)
 {
     yield return(extraFieldSource);
 }
 public CandidateValidation(ValidationFieldSource extraFieldSource, CandidateValidation candidateValidation)
 {
     Validation = candidateValidation.Validation;
     Fields     = candidateValidation.Fields.Concat(Enumerate(extraFieldSource)).ToList();
 }
Exemple #5
0
 public static bool Check(ValidationFieldSource source)
 {
     return(Check(source.Field.Type, source.TargetField.TargetFieldInfo.Type));
 }