示例#1
0
        /// <summary>
        ///     Validates the objects fields content
        /// </summary>
        /// <param name="validationType">Validation level to use on this model</param>
        /// <exception cref="OrderFieldBadFormatException">
        ///     throws an exception if one of the parameters doesn't match the expected
        ///     format
        /// </exception>
        public virtual void Validate(Validations validationType = Validations.Weak)
        {
            InputValidators.ValidateValuedString(Title, "Title");
            InputValidators.ValidateZeroOrPositiveValue(Price.GetValueOrDefault(), "Price");
            InputValidators.ValidatePositiveValue(QuantityPurchased.GetValueOrDefault(), "Quantity Purchased");

            // optional fields validations
            if (ProductId != null)
            {
                InputValidators.ValidateValuedString(ProductId, "Product Id");
            }

            Seller?.Validate(validationType);
        }