Beispiel #1
0
		/// <summary>
		/// Initializes a new FieldError structure.
		/// </summary>
		/// <remarks>Validates the given value and sets the <see cref="ErrorCode"/> property.</remarks>
		/// <param name="field">Field.</param>		
		/// <param name="value">Value that has been tested.</param>
		public FieldError(IDbColumn field, object value)
		{
			this.field = field;			
			this.value = value;
			FieldValidator validator = new FieldValidator(field);
			this.errorCode = validator.Validate(value);
		}
 /// <summary>
 /// Checks whether the given value is valid for this column.
 /// </summary>
 /// <remarks>Checks whether the value contained in the given field obeys basic constraints
 /// (nullability, min/max value etc). Returns <see cref="FieldErrorCode"/> that indicates
 /// the type of error encountered.</remarks>
 /// <param name="value">Value.</param>
 /// <returns>Error code.</returns>
 /// <example>
 /// The folowing example tests values against the HireDate field of the Northwind's Employees table.
 /// HireDate is a nullable T-SQL DateTime type (SQL Server). Minimum DateTime value supported by SQL Server is January 1, 1753.
 /// <code>
 /// EmployeesMeta employees = new EmployeesMeta();
 ///
 /// // The field is nullable.
 /// // Validate method returns FieldErrorCode.AllOk.
 /// FieldErrorCode allOk = employees.HireDate.Validate(null);
 ///
 /// // Minimum DateTime value supported by SQL Server is January 1, 1753.
 /// // Validate method returns FieldErrorCode.OutOfRangeError.
 /// FieldErrorCode outOfRangeError = employees.HireDate.Validate(new DateTime(1000, 1, 1));
 ///
 /// // The field cannot accept integer values.
 /// // Validate method returns FieldErrorCode.NonCompatibileType.
 /// FieldErrorCode nonCompatibileType = employees.HireDate.Validate(0);
 /// </code>
 /// </example>
 public FieldErrorCode Validate(object value)
 {
     FieldValidator validator = new FieldValidator(this);
     return validator.Validate(value);
 }