public BrokenRule(string name, string desc, string propName, ValidationSeverity sev) { Description = desc + ""; Reason = Description; RuleName = name + ""; Severity = sev; }
public ValidationIssue(object subject, ValidationSeverity severity, string message, object viewdata = null) { Severity = severity; Message = message; Subject = subject; ViewData = viewdata; }
public static ValidationOptions WithValidationSeverity( this ValidationOptions options, ValidationSeverity validationSeverity) { options.ValidationSeverity = validationSeverity; return(options); }
private IValidationContext CreateValidationContext(ValidationSeverity validationSeverity) { return(new ServiceCollection() .AddValidation(o => o.ValidationSeverity = validationSeverity) .BuildServiceProvider() .GetRequiredService <IValidationContext>()); }
public ValidationIssue(object subject, ValidationSeverity severity, string message, object viewdata=null) { Severity = severity; Message = message; Subject = subject; ViewData = viewdata; }
public IEnumerable <IBrokenRule> BrokenValidationsForSeverity(ValidationSeverity severity) { CheckValidations(); return(from itm in BrokenValidations where itm.Severity == severity select itm); }
public ValidationResult(ValidationSeverity severity, string propertyName, string text) { Severity = severity; PropertyName = propertyName; Text = text; }
/// <summary> /// Adds <see cref="ValidationDetail" /> to <see cref="IValidationContext" /> with specified /// <see cref="ValidationSeverity" /> /// </summary> /// <exception cref="ValidationConditionException"> /// Throws when ValidationDetail.ValidationSeverity greater ValidationContext.ValidationSeverity. /// Example: Add fatal detail, when validation context severity is error /// </exception> public static ValidationDetail?AddValidationDetail( this IValidationCondition condition, string validationMessage, ValidationSeverity validationSeverity = ValidationSeverity.Error) { var validationContext = condition.ValidationContext; var validationDetail = new ValidationDetail( validationContext, condition.ValidationKey, validationMessage, validationSeverity, condition.IsValid ?? false); // Not null or false // Null by default, so validationContext.When(...).AddValidationDetail(...) works without additional conditions if (validationDetail.IsValid) { return(validationDetail); } validationContext.ValidationDetails.Add(validationDetail); if (validationDetail.ValidationSeverity > validationContext.ValidationSeverity) { throw new ValidationConditionException(validationDetail); } return(validationDetail); }
public ValidationMessage(string message, ValidationSeverity severity, params string[] members) { Message = message; Severity = severity; Members = members; }
public RepositoryCheckoutValidation(Pipeline pipeline) { _resources = pipeline.Resources?.FlattenDefinitions() ?? Array.Empty <Resources>(); _steps = pipeline.Stages .SelectMany(stage => stage.FlattenDefinitions()) .SelectMany(stage => stage.Jobs.GetSteps()); _severity = SharplinerConfiguration.Current.Validations.RepositoryCheckouts; }
public ValidationMessage( ValidationSeverity severity, string message ) { Severity = severity; Message = message; }
public BrokenRule(string name, string desc, string propName, ValidationSeverity sev, object objectBroke) { Description = desc + ""; RuleName = name + ""; ObjectBroke = objectBroke.GetType().Name;; Severity = sev; Reason = Description; }
public Validation(string key, ValidationSeverity severity, string validationmessage, string overRideInstructions, Dictionary <string, string> options) : this(key, severity, validationmessage, overRideInstructions) { if (options == null) { options = new Dictionary <string, string>(); } this.Options = options; }
public static Result CreateResultForFailure(ValidationSeverity validationSeverity, string parameterName, string message, int rowKey = int.MinValue) { return(validationSeverity switch { ValidationSeverity.Error => ResultFactory.Error(parameterName, message, rowKey), ValidationSeverity.Warning => ResultFactory.Warning(parameterName, message, rowKey), _ => throw new System.NotImplementedException() });
public static IRule GuidEmpty(string propname, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <Guid, Guid> newValidation = new ClientSideValidationRule <Guid, Guid>("GUID Empty", "Item must be empty.", propname, CommonPropRuleHandlers.EmptyGuidHandler); newValidation.Severity = severity; return(newValidation); }
public static IRule NotEmptyStringValidation(string PropName = null, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <string, string> newValidation = new ClientSideValidationRule <string, string>("Not Empty", "Value cannot be empty.", PropName, CommonPropRuleHandlers.NonBlankStringHandler); newValidation.Severity = severity; return(newValidation); }
public static IRule DateNotMaxValidation(string propname, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <DateTime, object> newValidation = new ClientSideValidationRule <DateTime, object>("Date Not Max", "Date must be less than " + DateTime.MaxValue.ToString() + ".", propname, CommonPropRuleHandlers.DateNotMinHandler); newValidation.Severity = severity; return(newValidation); }
public static IRule MustBeNullOrNumeric(string propname, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <object, object> newValidation = new ClientSideValidationRule <object, object>("Must Be Null Or Numeric", "Value {0} is not a valid number.".FormatStr(propname), propname, CommonPropRuleHandlers.IsNumberBroke); newValidation.Severity = severity; return(newValidation); }
public static IRule DateNotMinValidation(string propname, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <DateTime, object> newValidation = new ClientSideValidationRule <DateTime, object>("Date Not Min", "Date must be set.", propname, CommonPropRuleHandlers.DateNotMinHandler); newValidation.Severity = severity; return(newValidation); }
public static IRule NotNothingValidation(string propName, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <object, object> newValidation = new ClientSideValidationRule <object, object>("Not Nothing", "Value must be set.", propName, CommonPropRuleHandlers.NotNullHandler); newValidation.Severity = severity; return(newValidation); }
public static IRule BetweenValidation(string propname, IDateRange range, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <DateTime, IDateRange> newValidation = new ClientSideValidationRule <DateTime, IDateRange>("Date Between", "Date must be between " + range.FirstValidDate.ToString() + " and " + range.LastValidDate.ToString() + ".", propname, CommonPropRuleHandlers.DateRangeHandler); newValidation.AllowedValue = range; newValidation.Severity = severity; return(newValidation); }
public ValidationResult(bool pIsOk, string pMessage, ValidationSeverity pSeverity, string pPropertyName) { this._isOk = pIsOk; this._message = pMessage; this._severity = pSeverity; this._propertyName = pPropertyName; if (!this._isOk && (this._severity == ValidationSeverity.NA)) { this._severity = ValidationSeverity.Error; } }
public static IRule LessThanValidation(string propname, IComparable value, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <IComparable, IComparable> newValidation = new ClientSideValidationRule <IComparable, IComparable>("Less Than", "Value must be less than " + value?.ToString() + ".", propname, CommonPropRuleHandlers.LessThanHandler); newValidation.AllowedValue = value; newValidation.Severity = severity; return(newValidation); }
public static IRule NotEqualToValidation(string propname, IComparable value, ValidationSeverity severity = ValidationSeverity.Critical) { ClientSideValidationRule <IComparable, IComparable> newValidation = new ClientSideValidationRule <IComparable, IComparable>("Not Equal To", "Value must not be equal to " + value.ToString() + ".", propname, CommonPropRuleHandlers.NotEqualToHandler); newValidation.AllowedValue = value; newValidation.Severity = severity; return(newValidation); }
public static void Deconstruct( this ValidationDetail validationDetail, out string validationKey, out string validationMessage, out bool isValid, out ValidationSeverity validationSeverity) { validationKey = validationDetail.ValidationKey; validationMessage = validationDetail.ValidationMessage; isValid = validationDetail.IsValid; validationSeverity = validationDetail.ValidationSeverity; }
public ValidationDetail( IValidationContext validationContext, string validationKey, string validationMessage, ValidationSeverity validationSeverity, bool isValid) { ValidationContext = validationContext; ValidationKey = validationKey ?? throw new ArgumentNullException(nameof(validationKey)); ValidationMessage = validationMessage ?? throw new ArgumentNullException(nameof(validationMessage)); ValidationSeverity = validationSeverity; IsValid = isValid; }
public static IList<ValidationIssue> ValidateDuplicateNames(IEnumerable<INameable> nameables, string typeNamePlural, object viewData, ValidationSeverity severity = ValidationSeverity.Error) { var issues = new List<ValidationIssue>(); var nonUniqueNames = GetNonUniqueNames(nameables); foreach (var nonUniqueName in nonUniqueNames) { var first = nameables.First(n => n.Name == nonUniqueName); issues.Add( new ValidationIssue(first, severity, String.Format("Several {0} with the same id exist", typeNamePlural), viewData)); } return issues; }
public Validation(string key, ValidationSeverity severity, string validationMessage) : this() { this.Key = !string.IsNullOrEmpty(key) ? key : throw new ArgumentNullException("Key"); this.ValidationMessage = !string.IsNullOrEmpty(validationMessage) ? validationMessage : throw new ArgumentNullException("ValidationMessage"); this.Severity = severity; this.Options = new Dictionary <string, string>(); this.OverRideInstructions = string.Empty; switch (severity) { case ValidationSeverity.Escalate: this.OverRideInstructions = "Override?"; break; case ValidationSeverity.Confirm: this.OverRideInstructions = "Confirm?"; break; } }
/// <summary> /// Initializes a new instance of the <see cref="ValidationResult"/> class. /// </summary> /// <param name="propertyName">Name of the property to which this <see cref="ValidationResult"/> belongs.</param> /// <param name="message">The message of this <see cref="ValidationResult"/>.</param> /// <param name="severity">The severity of the <see cref="ValidationResult"/>. This parameter is optional. /// <br/>Default value: <see cref="ValidationSeverity.Error"/>.</param> public ValidationResult(string propertyName, string message, ValidationSeverity severity = ValidationSeverity.Error) { if (propertyName == null) { Throw.ArgumentNullException(Argument.propertyName); } if (message == null) { Throw.ArgumentNullException(Argument.message); } PropertyName = propertyName; Message = message; if (!Enum <ValidationSeverity> .IsDefined(severity)) { Throw.EnumArgumentOutOfRangeWithValues(Argument.severity, severity); } Severity = severity; }
/// <summary> /// Adds a message for given key. /// </summary> public void Add(ValidationSeverity severity, string key, string text) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (text == null) { throw new ArgumentNullException(nameof(text)); } Add(new ValidationMessage() { Severity = severity, Key = key, Text = text, }); }
/// <summary> /// Creates a new validation using the specified field, message and severity. /// </summary> /// <param name="field">The field.</param> /// <param name="message">The message.</param> /// <param name="severity">The severity.</param> /// <returns>A new validation</returns> public static BaseValidation Create(string field, string message, ValidationSeverity severity) { return Create(field, message, Guid.Empty, severity); }
/// <summary> /// Creates a new validation using the specified field and severity. /// </summary> /// <param name="field">The field.</param> /// <param name="entityID">The entity ID.</param> /// <param name="severity">The severity.</param> /// <returns> /// A new validation /// </returns> public static BaseValidation Create(string field, Guid entityID, ValidationSeverity severity) { return Create(field, null, entityID, severity); }
public static IList <ValidationIssue> ValidateDuplicateNames(IEnumerable <INameable> nameables, string typeNamePlural, object viewData, ValidationSeverity severity = ValidationSeverity.Error) { var issues = new List <ValidationIssue>(); var nonUniqueNames = GetNonUniqueNames(nameables); foreach (var nonUniqueName in nonUniqueNames) { var first = nameables.First(n => n.Name == nonUniqueName); issues.Add( new ValidationIssue(first, severity, String.Format("Several {0} with the same id exist", typeNamePlural), viewData)); } return(issues); }
/// <summary> /// Creates a new validation using the specified field, message and severity. /// </summary> /// <param name="field">The field.</param> /// <param name="message">The message.</param> /// <param name="entityID">The entity ID.</param> /// <param name="severity">The severity.</param> /// <returns> /// A new validation /// </returns> public static BaseValidation Create(string field, string message, Guid entityID, ValidationSeverity severity) { switch (severity) { case ValidationSeverity.Suggestion: return new ValidationSuggestion(field, message, entityID); case ValidationSeverity.Warning: return new ValidationWarning(field, message, entityID); case ValidationSeverity.Error: return new ValidationError(field, message, entityID); default: throw new ArgumentOutOfRangeException("severity"); } }
public Validation(string key, ValidationSeverity severity, string validationMessage, string overRideInstructions) : this() { this.OverRideInstructions = string.IsNullOrEmpty(overRideInstructions) ? this.OverRideInstructions : overRideInstructions; }