Esempio n. 1
0
 public ValidationError(ValidationErrorResult validationResult)
     : base(validationResult.ErrorMessage)
 {
     this.errorCode    = validationResult.ErrorCode;
     this.ErrorMessage = validationResult.ErrorMessage;
     this.Violations   = validationResult.Errors;
 }
Esempio n. 2
0
 public static void ThrowIfNotValid(ValidationErrorResult validationResult)
 {
     if (!validationResult.IsValid)
     {
         throw new ValidationError(validationResult);
     }
 }
Esempio n. 3
0
 public ValidationError(ValidationErrorResult validationResult)
     : base(validationResult.ErrorMessage)
 {
     this.errorCode = validationResult.ErrorCode;
     this.ErrorMessage = validationResult.ErrorMessage;
     this.Violations = validationResult.Errors;
 }
        /// <summary>
        /// Converts the validation result to an error result which will be serialized by SStack in a clean and human-readable way.
        /// </summary>
        /// <param name="result">The validation result</param>
        /// <returns></returns>
        public static ValidationErrorResult ToErrorResult(this ValidationResult result)
        {
            var validationResult = new ValidationErrorResult();
            foreach (var error in result.Errors)
                validationResult.Errors.Add(new ValidationErrorField(error.ErrorCode, error.PropertyName, error.ErrorMessage, error.AttemptedValue));

            return validationResult;
        }
Esempio n. 5
0
 /// <summary>
 /// Merge errors from another <see cref="ValidationErrorResult"/>
 /// </summary>
 /// <param name="result"></param>
 public void Merge(ValidationErrorResult result)
 {
     if (result != null)
     {
         foreach (var e in result.Errors)
         {
             Errors.Add(e);
         }
     }
 }
Esempio n. 6
0
        public static object CreateErrorResponse(object request, ValidationErrorResult validationError)
        {
            var responseStatus = validationError.ToResponseStatus();

            var errorResponse = CreateErrorResponse(
                request,
                new ValidationError(validationError),
                responseStatus);

            return errorResponse;
        }
Esempio n. 7
0
 public static void ThrowIfNotValid(ValidationErrorResult validationResult)
 {
     if (!validationResult.IsValid)
     {
         throw new ValidationError(validationResult);
     }
 }
Esempio n. 8
0
		/// <summary>
		/// Merge errors from another <see cref="ValidationErrorResult"/>
		/// </summary>
		/// <param name="result"></param>
		public void Merge(ValidationErrorResult result)
		{
			if (result != null) {
				foreach (var e in result.Errors) {
					Errors.Add(e);
				}
			}
		}