예제 #1
0
        private void TestInjectValueValidate(PropertyContext <TestInject, object> context)
        {
            var vxc = Validator <TestInjectChild> .Create()
                      .HasProperty(x => x.Code, p => p.Mandatory().CompareValue(CompareOperator.GreaterThan, 10));

            var type = vxc.GetType();
            var mi   = type.GetMethod("Validate");
            var vc   = mi.Invoke(vxc, new object[] { context.Value, context.CreateValidationArgs() });

            context.Parent.MergeResult((Beef.Validation.IValidationContext)vc);
        }
예제 #2
0
        /// <summary>
        /// Validate the property value.
        /// </summary>
        /// <param name="context">The <see cref="PropertyContext{TEntity, TProperty}"/>.</param>
        public override void Validate(PropertyContext <TEntity, TProperty> context)
        {
            // Exit where nothing to validate.
            if (context.Value == null)
            {
                return;
            }

            // Create the context args.
            var args = context.CreateValidationArgs();

            // Validate and merge.
            context.MergeResult(Validator.Validate(context.Value, args));
        }