/// <summary> /// A convenience method to check the validity of 'value' and, if not valid, /// generate an error message and report an error. /// /// If you don't want the default error (InvalidParameterException) use: /// <code> /// if( ! mExampleValueLimits.IsValid( value ) { /// ErrorLog.ThrowException( new MyException( ... ) ); /// } /// </code> /// </summary> /// <param name="value">the value to check</param> /// <param name="fieldName">user visible name of field/parameter</param> /// <param name="errorLog">the ErrorLog used to report errors ... may be empty</param> public void CheckValidity(T value, string fieldName, IErrorLog errorLog) { if (!IsValid(value)) { // Not valid ... generate error message and report error... Exception ex = new InvalidParameterException(RangeValidationErrorMessage(value, fieldName)); if (errorLog == null) { throw ex; } errorLog.ThrowException(ex); } }