public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (value is string stringVal) { if (stringVal.Length > _maxLength) { UpdateVal(val, value, stringVal.Length); } } else if (value is ICollection collection) { var len = collection.Count; if (len > _maxLength) { UpdateVal(val, value, len); } } return(val); }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; var flag = true; if (value is ICollection collection) { if (collection.Cast <object>().Any(one => !_func.Invoke(one))) { flag = false; } if (!flag) { UpdateVal(val, value); } } else { UpdateVal(val, value, "The type is not a collection or an array, and an exception occurs when using AllToken."); } return(val); }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (value is string stringVal) { if (stringVal.Length < _minLength) { UpdateVal(val, value, stringVal.Length); } } else if (Member.MemberType == typeof(string) && _minLength > 0) { UpdateVal(val, value, 0); } else if (value is ICollection collection) { var len = collection.Count; if (len < _minLength) { UpdateVal(val, value, len); } } return(val); }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (_types.Any()) { var flag = false; var typeOfValue = value?.GetType(); foreach (var type in _types) { if (Member.MemberType == type || (typeOfValue != null && typeOfValue == type)) { flag = true; break; } if (Member.MemberType.IsDeriveClassFrom(type)) { flag = true; break; } } if (!flag) { UpdateVal(val, value); } } return(val); }
private void UpdateVal(CorrectVerifyVal val, object obj, string message) { if (string.IsNullOrWhiteSpace(message)) { message = "The value does not satisfy the given Func condition."; } val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message); }
public override CorrectVerifyVal ValidValue(TVal value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (_objects.Contains(value)) { UpdateVal(val, value); } return(val); }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal {NameOfExecutedRule = NAME}; var success = !ValidCore(value); if (!success) { UpdateVal(val, value); } return val; }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (!ValidCore(value)) { UpdateVal(val, value); } return(val); }
private void UpdateVal(CorrectVerifyVal val, object obj, string expression = null) { var message = "The regular expression match failed."; if (!string.IsNullOrWhiteSpace(expression)) { message += $" The current expression is: {expression}."; } val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message); }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; var regex = _regexFunc(value); if (regex == null || value == null || !regex.IsMatch((string)value)) { UpdateVal(val, value, regex?.ToString()); } return(val); }
public override CorrectVerifyVal ValidValue(TVal value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; var result = _func.Invoke(value); if (result != null && !result.VerifyResult) { UpdateVal(val, value, result.ErrorMessage); } return(val); }
public override CorrectVerifyVal ValidValue(TVal value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; var success = ValidCore(value, out var message); if (!success) { UpdateVal(val, value, message); } return(val); }
public override CorrectVerifyVal ValidValue(object value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (value is decimal decimalValue) { var scale = GetScale(decimalValue); var precision = GetPrecision(decimalValue); var actualIntegerDigits = precision - scale; var expectedIntegerDigits = Precision - Scale; if (scale > Scale || actualIntegerDigits > expectedIntegerDigits) { UpdateVal(val, value, scale, actualIntegerDigits); } } return(val); }
public override CorrectVerifyVal ValidValue(TVal value) { var val = new CorrectVerifyVal { NameOfExecutedRule = NAME }; if (value is null) { UpdateVal(val, default); } if (value is IComparable <TVal> comparable) { if (_options == RangeOptions.OpenInterval) { // Open Interval if (comparable.CompareTo(_from) <= 0 || comparable.CompareTo(_to) >= 0) { UpdateVal(val, value); } } else { // Close Interval if (comparable.CompareTo(_from) < 0 || comparable.CompareTo(_to) > 0) { UpdateVal(val, value); } } } else { UpdateVal(val, value, "The given value cannot be compared."); } return(val); }
private void UpdateVal(CorrectVerifyVal val, object obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? $"The given value must be less than or equal to {_valueToCompare}."); }
private void UpdateVal(CorrectVerifyVal val, object obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? $"'{VerifiableMember.MemberName}' has a range of values which does not include '{obj}'."); }
private void UpdateVal(CorrectVerifyVal val, object obj, int currentLength) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage($"The array length should be greater than {_minLength} and less than {_maxLength}, and the current length is {currentLength}."); }
private void UpdateVal(CorrectVerifyVal val, TVal obj) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage($"The two values given must be equal. The current value is: {obj} and the value being compared is {_valueToCompare}."); }
private void UpdateVal(CorrectVerifyVal val, TVal obj) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(GetDefaultMessageSinceToken(obj)); }
/// <inheritdoc /> protected override void UpdateVal(CorrectVerifyVal val, object obj, object valueToCompare, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? $"The given value must be less than {valueToCompare}."); }
private void UpdateVal(CorrectVerifyVal val, object obj, int actualScale, int actualIntegerDigits) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage($"The given value must not be more than {Precision} digits in total, with allowance for {Scale} decimals. {actualIntegerDigits} digits and {actualScale} decimals were found."); }
private void UpdateVal(CorrectVerifyVal val, TVal obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? $"The given value is not in the valid range. The current value is: {obj}, and the valid range is from {_from} to {_to}."); }
protected virtual void UpdateVal(CorrectVerifyVal val, object obj, object valueToCompare, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? $"The given value does not meet the requirements."); }
private void UpdateVal(CorrectVerifyVal val, TVal obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? $"The values must not be equal. The current value type is: {Member.MemberType.GetDevelopName()}."); }
private void UpdateVal(CorrectVerifyVal val, TVal obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? "There are no members that meet the conditions in the array or collection."); }
private void UpdateVal(CorrectVerifyVal val, object obj) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage("The given value is not a member of the specified enumeration type."); }
private void UpdateVal(CorrectVerifyVal val, object obj) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage($"The given type is not a derived class of {_type.GetDevelopName()} or its implementation. The current type is {Member.MemberType.GetDevelopName()}."); }
private void UpdateVal(CorrectVerifyVal val, TVal obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? "There is at least one unsatisfied member in the array or collection."); }
private void UpdateVal(CorrectVerifyVal val, object obj, string message = null) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage(message ?? "The value is not contained in the given value array or collection."); }
private void UpdateVal(CorrectVerifyVal val, object obj) { val.IsSuccess = false; val.VerifiedValue = obj; val.ErrorMessage = MergeMessage("The value is must be null."); }