internal ValidationResult(ValidationKind type, string message, bool isSuccess = true, bool isApplicable = true) { this.Type = type; this.IsSuccess = isSuccess; this.IsApplicable = isApplicable; this.Message = message; }
private void WriteNotApplicableResult(ILWriter writer, ValidationKind kind) { var notApplicable = KnownMetadata.Methods.ValidationResult_NotApplicable; writer.LoadInt32((int)kind); writer.StaticMethodCall(notApplicable); }
/// <summary> /// Initializes a new instance of the <see cref="ValidationError"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="source">The source.</param> /// <param name="kind">The kind .</param> /// <param name="members">The members.</param> public ValidationError(string message, object source, ValidationKind kind, AllorsEmbeddedRelationType[] members) { this.source = source; this.members = members; this.kind = kind; this.message = message; }
private OperationResult CheckValidation() { OperationResult result; ValidationKind validationKind = CheckValidationKind(); bool repeat = CheckValidationRepeat(); Validator validator = new Validator(validationKind); if (repeat) { result = validator.RepeatValidation(); } else { if (_parameters.Count > 0) { string number = _parameters.Dequeue(); result = validator.ValidateOne(number); } else { result = new OperationResult { Code = (Statuscode)(-1) }; } } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="ValidationError"/> class. /// </summary> /// <param name="message">The message.</param> /// <param name="source">The source.</param> /// <param name="kind">The kind .</param> /// <param name="members">The members.</param> public ValidationError(string message, object source, ValidationKind kind, string[] members) { this.source = source; this.members = members; this.kind = kind; this.message = message; }
private void WriteFailureResult(ILWriter writer, ValidationKind kind, string message) { var failure = KnownMetadata.Methods.ValidationResult_Failure; writer.LoadInt32((int)kind); writer.LoadString(message); writer.StaticMethodCall(failure); }
/// <summary> /// Initializes a new instance of the <see cref="ValidationBase" /> class. /// </summary> /// <param name="validationName">Name of the validation.</param> /// <param name="validationType">Type of the validation.</param> /// <param name="validationKind">Kind of the validation.</param> public ValidationBase( string validationName, ValidationType validationType, ValidationKind validationKind) { DisplayName = validationName; ValidationKind = validationKind; ValidationType = validationType; SuccessfulResult = ValidationResult.SuccessfullValidationResult(validationType, validationKind); }
public BaseValidation( string validationName, ValidationType validationType, ValidationKind validationKind) { this.DisplayName = validationName; this.ValidationKind = validationKind; this.ValidationType = validationType; this.SuccessfulResult = ValidationResult.SuccessfullValidationResult(validationType, validationKind); }
internal ValidationResult AddResult(string message, ValidationKind kind) { ValidationResult result = null; Add(result = new ValidationResult { Message = message, Kind = kind, Exception = new ValidationException(message) }); return(result); }
public static IValidationResult Validate <T> (ValidationKind validationKind, T[] validationParameters, T checkedObject) { switch (validationKind) { case ValidationKind.Unique: object[] validationParametersObjectArray = new object[validationParameters.Length]; validationParameters.CopyTo(validationParametersObjectArray, 0); UniqueValidator <T> validator = new UniqueValidator <T>(validationParametersObjectArray, checkedObject); return(validator.Validate( )); default: throw new NotImplementedException("Not implemented switch in ValidatorProvider.Validate()"); } }
/// <summary> /// Converts the specified value. /// </summary> /// <param name="value">The value.</param> /// <returns>PSValidationKind.</returns> /// <exception cref="ArgumentException"></exception> private PSValidationKind Convert(ValidationKind value) { switch (value) { case ValidationKind.SystemValidation: return(PSValidationKind.SystemValidation); case ValidationKind.NamespaceValidation: return(PSValidationKind.NamespaceValidation); default: throw new ArgumentException(string.Format(StorageSyncResources.UnsupportedErrorFormat, value.GetType().Name, value)); } }
private PSValidationKind Convert(ValidationKind value) { switch (value) { case ValidationKind.SystemValidation: return(PSValidationKind.SystemValidation); case ValidationKind.NamespaceValidation: return(PSValidationKind.NamespaceValidation); default: throw new ArgumentException($"{value.GetType().Name} value {value} is unsupported"); } }
public ViewModelCollectionPropertyDescriptor <TOwner, TResult> Validate( Func <TOwner, TResult, bool> condition, ValidationKind kind = ValidationKind.Error, string message = null, bool continueOnValidationError = true, bool notifyChangeOnValidationError = true) { ValidationRecords.Add(new ValidationRecord() { Validate = (vm, x, res) => res.Validate(condition(vm, x), message, kind), ContinueOnValidationError = continueOnValidationError, NotifyChangeOnValidationError = notifyChangeOnValidationError }); return(this); }
public ViewModelCollectionPropertyDescriptor <TOwner, TResult> Validate <TValidator>( ValidationKind kind = ValidationKind.Error, string message = null, bool continueOnValidationError = true, bool notifyChangeOnValidationError = true) where TValidator : IValidator, new() { ValidationRecords.Add(new ValidationRecord() { Validate = (vm, x, res) => res.Validate <TValidator>(x, message, kind), ContinueOnValidationError = continueOnValidationError, NotifyChangeOnValidationError = notifyChangeOnValidationError }); return(this); }
public ViewModelPropertyDescriptor <TOwner, TResult> Validate( IValidator validator, ValidationKind kind = ValidationKind.Error, string message = null, bool continueOnValidationError = true, bool notifyChangeOnValidationError = true, ValidationErrorBehavior when = ValidationErrorBehavior.AfterCoerce) { ValidationRecords.Add(new ValidationRecord() { Validate = (vm, x, res) => res.Validate(validator, x, message, kind), ContinueOnValidationError = continueOnValidationError, NotifyChangeOnValidationError = notifyChangeOnValidationError, BehaviorOnCoerce = when }); return(this); }
private static void RecordResultAndResetStopwatches( this List <BenchmarkResult> results, IReadOnlyDictionary <BenchmarkSignatureKind, Stopwatch> benchmarkKindToStopwatchMap, ValidationKind validationKind, OutcomeKind outcomeKind) { foreach (var benchmarkSignature in benchmarkKindToStopwatchMap.Keys) { var stopwatch = benchmarkKindToStopwatchMap[benchmarkSignature]; var benchmarkResult = new BenchmarkResult { BenchmarkSignatureKind = benchmarkSignature, ValidationKind = validationKind, OutcomeKind = outcomeKind, Elapsed = stopwatch.Elapsed, }; results.Add(benchmarkResult); stopwatch.Reset(); } }
public BrokenAttributeValidator(Type brokenValidatorType, ValidationKind kind, string message) { //this.brokenValidatorType = brokenValidatorType; this.kind = kind; this.message = message; }
/// <summary> /// Adds a new validation error. /// </summary> /// <param name="message">The message.</param> /// <param name="source">The source.</param> /// <param name="kind">The kind.</param> /// <param name="members">The members.</param> public void AddError(string message, object source, ValidationKind kind, params string[] members) { this.errors.Add(new ValidationError(message, source, kind, members)); }
public Validator(ValidationKind validationKind) { _validationKind = validationKind; }
public static IValidationResult NotApplicable(ValidationKind type) { return new ValidationResult(type, CommonResults.ValidationNotApplicable.WithValues(type.ToString()), isSuccess: false, isApplicable: false); }
public ValidationResult Validate <TValidator>(object value, string message, ValidationKind kind) where TValidator : IValidator, new() => Validate(new TValidator(), value, message, kind);
public static IValidationResult NotApplicable(ValidationKind type) { return(new ValidationResult(type, CommonResults.ValidationNotApplicable.WithValues(type.ToString()), isSuccess: false, isApplicable: false)); }
public static IValidationResult Failure(ValidationKind type, string message) { return(new ValidationResult(type, message, isSuccess: false)); }
internal void AddValidationResult(TOwner owner, string propertyName, string message, ValidationKind kind) { ValidationResults.AddResult(message, kind); owner.OnErrorChanged(propertyName); }
public BaseValidationAttribute(string errorMessageSnippet, ValidationKind kind) { this.ErrorMessageSnippet = errorMessageSnippet; this.ValidatorKind = kind; }
public ValidationResult Validate(bool condition, string message, ValidationKind kind) => condition?AddResult(message, kind) : null;
/// <summary> /// Successfulls the validation result. /// </summary> /// <param name="validationType">Type of the validation.</param> /// <param name="validationKind">Kind of the validation.</param> /// <returns>IValidationResult.</returns> public static IValidationResult SuccessfullValidationResult(ValidationType validationType, ValidationKind validationKind) { return(new ValidationResult { Type = validationType, Kind = validationKind, Level = ResultLevel.Info, Result = Result.Success, Description = "Validation succeeded." }); }
public ValidationResult Validate(IValidator validator, object value, string message, ValidationKind kind) { ValidationResult result = null; if (validator.Validate(value, message) is string msg) { Add(result = new ValidationResult { Message = msg, Kind = kind, Exception = new ValidationException(message) }); } return(result); }
/// <summary> /// Unavailables the validation. /// </summary> /// <param name="validationType">Type of the validation.</param> /// <param name="validationKind">Kind of the validation.</param> /// <param name="description">The description.</param> /// <returns>IValidationResult.</returns> public static IValidationResult UnavailableValidation(ValidationType validationType, ValidationKind validationKind, string description) { return(new ValidationResult { Type = validationType, Kind = validationKind, Level = ResultLevel.Warning, Result = Result.Unavailable, Description = description }); }
/// <summary> /// Unauthorizeds the access dir. /// </summary> /// <param name="validationType">Type of the validation.</param> /// <param name="validationKind">Kind of the validation.</param> /// <param name="dir">The dir.</param> /// <returns>IValidationResult.</returns> public static IValidationResult UnauthorizedAccessDir(ValidationType validationType, ValidationKind validationKind, IDirectoryInfo dir) { return(new ValidationResult { Type = validationType, Kind = validationKind, Level = ResultLevel.Warning, Result = Result.Unavailable, Description = "The directory could not be validated because the user is not authorized to access it.", Path = dir.FullName }); }
public static void AddValidationResult <T, TResult>(this T vm, Expression <Func <T, TResult> > propExp, string message, ValidationKind kind) where T : ViewModelBase <T> { var propertyName = (propExp.Body as MemberExpression).Member.Name; if (vm._values.TryGetValue(propertyName, out IViewModelProperty prop)) { ((ViewModelProperty <T, TResult>)prop).AddValidationResult(vm, propertyName, message, kind); } }
public static IValidationResult Failure(ValidationKind type, string message) { return new ValidationResult(type, message, isSuccess: false); }