/// <summary>
        /// Validates a given value against this rule.
        /// </summary>
        /// <param name="path">a dot notation path to the value.</param>
        /// <param name="schema">a schema this rule is called from</param>
        /// <param name="value">a value to be validated.</param>
        /// <param name="results">a list with validation results to add new results.</param>
        public void Validate(string path, Schema schema, object value, List <ValidationResult> results)
        {
            var name = path ?? "value";

            if (!ObjectComparator.Compare(value, _operation, _value))
            {
                results.Add(
                    new ValidationResult(
                        path,
                        ValidationResultType.Error,
                        "BAD_VALUE",
                        name + " must have " + _operation + " " + _value + " but found " + value,
                        _operation + " " + _value,
                        value
                        )
                    );
            }
        }
Exemple #2
0
        /// <summary>
        /// Validates a given value against this rule.
        /// </summary>
        /// <param name="path">a dot notation path to the value.</param>
        /// <param name="schema">a schema this rule is called from</param>
        /// <param name="value">a value to be validated.</param>
        /// <param name="results">a list with validation results to add new results.</param>
        public void Validate(string path, Schema schema, object value, List <ValidationResult> results)
        {
            var name   = path ?? "value";
            var value1 = ObjectReader.GetProperty(value, _property1);
            var value2 = ObjectReader.GetProperty(value, _property2);

            if (!ObjectComparator.Compare(value1, _operation, value2))
            {
                results.Add(
                    new ValidationResult(
                        path,
                        ValidationResultType.Error,
                        "PROPERTIES_NOT_MATCH",
                        name + " must have " + _property1 + " " + _operation + " " + _property2,
                        value2,
                        value1
                        )
                    );
            }
        }