public override string GetStringValue(FormValue value) { if (value.DateValue.HasValue) { if (value.DateValue.Value.TimeOfDay == TimeSpan.Zero) { return(value.DateValue.Value.ToString("dd/MM/yyyy")); } else { return(value.DateValue.Value.ToString("dd/MM/yyyy hh:mm tt")); } } return(string.Empty); }
public override IEnumerable <ValidationResult> ValidateValue(FormValue value) { if (Mandatory && value.NumericValue == null) { yield return(new ValidationResult("{0} is required.".FormatWith(ShortTitle))); } if (MinVal.HasValue && value.NumericValue.HasValue && MinVal.Value > value.NumericValue.Value) { yield return(new ValidationResult("{0} should be bigger than {1}.".FormatWith(ShortTitle, MinVal.Value.ToString()))); } if (MaxVal.HasValue && value.NumericValue.HasValue && MaxVal.Value < value.NumericValue.Value) { yield return(new ValidationResult("{0} should be bigger than {1}.".FormatWith(ShortTitle, MaxVal.Value.ToString()))); } }
public override IEnumerable <ValidationResult> ValidateValue(FormValue value) { if (Mandatory && (value.TextValue == null || value.TextValue.IsEmpty())) { yield return(new ValidationResult("{0} is required.".FormatWith(ShortTitle))); } if (value.TextValue != null && value.TextValue.Length > this.MaxLength) { yield return(new ValidationResult("Length of {0} should be less than {1}.".FormatWith(ShortTitle, MaxLength.ToString()))); } if (value.TextValue != null && value.TextValue.Length < this.MinLength) { yield return(new ValidationResult("Length of {0} should be more than {1}.".FormatWith(ShortTitle, MinLength.ToString()))); } }
public override IEnumerable <ValidationResult> ValidateValue(FormValue value) { var attachments = new List <Attachment>(); using (var content = new SurveyContext()) { attachments = content.Attachments.AsNoTracking().Where(a => a.FormValueId == value.Id).ToList(); } if (Mandatory && !attachments.Any()) { yield return(new ValidationResult("{0} is required.".FormatWith(ShortTitle))); } //foreach(var attachment in attachments) // if(attachment.FileSize > attachment.Type.MaxFileSize * 1024) // yield return new ValidationResult("Maximum file size for {0} attachments should be less than {1} KB.".FormatWith(attachment.Type.Name, attachment.Type.MaxFileSize.ToString())); }
public override string GetStringValue(FormValue value) { return(value.TextValue); }
public virtual IEnumerable <ValidationResult> ValidateValue(FormValue value) { return(Enumerable.Empty <ValidationResult>()); }
public virtual string GetStringValue(FormValue value) { return(string.Empty); }