Waw that was fast!!!... I send a patch for that bug yesterday! and Dario
commit that.
Check the trunk version!
and thank you for report this issue.


2009/9/25 oll <[email protected]>

>
> When adding an invalid message to the constraint validator context,
> there is an option to pass in a property name.
>
> public bool IsValid(object value, IConstraintValidatorContext
> constraintValidatorContext)
> {
>    constraintValidatorContext.AddInvalid<MyClass, string>(
>        "A message from above (with a property name from Func)",
>        x => x.Property1);
>    constraintValidatorContext.AddInvalid("A message from above (with
> a property name)", "Property1");
>
>    return false;
> }
>
> When calling:
>
> new ValidatorEngine().Validate(new MyClass());
>
> I would expect the invalid value returned to have the property name
> "Property1" but it is null. Looking at the code, it appears that the
> PropertyName property is ignored when transforming from InvalidMessage
> to InvalidValue - the code below is taken from
> "NHibernate.Validator.Engine.InvalidMessageTransformer"
>
> public IEnumerable<InvalidValue> Transform()
>                {
>                        foreach (var invalidMsg in
> constraintContext.InvalidMessages)
>                        {
>                                var interpolatedMessage =
> Interpolate(entity, invalidMsg.Message,
> validator);
>
>                                yield return new
> InvalidValue(interpolatedMessage, @class,
> propertyName, value, entity);
>                        }
>                }
>
> Is this the expected behaviour? Or should "propertyName" be
> "invalidMsg.PropertyName"?
>
> Thanks
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to