/// <summary> /// Runs the validation process. /// </summary> public ValidationStatus Validate() { if (UsePattern && patternRegex != null) { var matchStatus = patternRegex.IsMatch(value?.ToString() ?? string.Empty) ? ValidationStatus.Success : ValidationStatus.Error; if (Status != matchStatus) { Status = matchStatus; if (matchStatus == ValidationStatus.Success) { ValidationSucceeded?.Invoke(new ValidationSucceededEventArgs()); } else if (matchStatus == ValidationStatus.Error) { ValidationFailed?.Invoke(new ValidationFailedEventArgs(null)); } Validated?.Invoke(new ValidatedEventArgs(Status, null)); StateHasChanged(); } } else { var handler = Validator; if (handler != null) { Validating?.Invoke(); var args = new ValidatorEventArgs(value); handler(args); if (Status != args.Status) { Status = args.Status; if (args.Status == ValidationStatus.Success) { ValidationSucceeded?.Invoke(new ValidationSucceededEventArgs()); } else if (args.Status == ValidationStatus.Error) { ValidationFailed?.Invoke(new ValidationFailedEventArgs(args.ErrorText)); } Validated?.Invoke(new ValidatedEventArgs(Status, args.ErrorText)); StateHasChanged(); } } } return(Status); }
/// <summary> /// Runs the validation process. /// </summary> public ValidationStatus Validate() { var handler = Validator; if (handler != null) { Validating?.Invoke(); var args = new ValidatorEventArgs(value); handler(args); if (Status != args.Status) { Status = args.Status; if (args.Status == ValidationStatus.Success) { ValidationSucceeded?.Invoke(new ValidationSucceededEventArgs()); } else if (args.Status == ValidationStatus.Error) { ValidationFailed?.Invoke(new ValidationFailedEventArgs(args.ErrorText)); } Validated?.Invoke(new ValidatedEventArgs(Status, args.ErrorText)); StateHasChanged(); } } return(Status); }
void SetPropertyValue <T>(T value, bool ignoreValidationResult, string memberName, Action setPropertyAction) { string result = null; if (ValidateProperty(memberName, value, out result) || ignoreValidationResult) { setPropertyAction(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName)); } else { InvalidateProperties(); ValidationFailed?.Invoke(this, result); } }
/// <summary> /// Runs the validation process. /// </summary> public ValidationStatus Validate() { var handler = Validator; //Status = ValidationStatus.None; if (handler != null) { Validating?.Invoke(); var args = new ValidatorEventArgs(value); handler(args); if (Status != args.Status) { Status = args.Status; if (args.Status == ValidationStatus.Success) { ValidationSucceeded?.Invoke(new ValidationSucceededEventArgs()); } else if (args.Status == ValidationStatus.Error) { ValidationFailed?.Invoke(new ValidationFailedEventArgs(args.ErrorText)); } Validated?.Invoke(new ValidatedEventArgs(Status, args.ErrorText)); StateHasChanged(); } } // force the reload of all child components //StateHasChanged(); return(Status); }
internal void OnValidationFailed(EntityRecord record) { ValidationFailed?.Invoke(record, EventArgs.Empty); }