i is valid because i.Address is not empty (its just an empty address
object).

-Markus
2009/7/28 bdaniel7 <[email protected]>

>
> Hello, i have the following setup:
>
> [ActiveRecord(Lazy = true, DynamicInsert = true, DynamicUpdate = true,
> SelectBeforeUpdate = true)]
> public class Incident : ActiveRecordValidationBase<Incident>
> {
>    Address address;
>
>    [BelongsTo(Cascade = CascadeEnum.SaveUpdate, Update=false)]
>    [ValidateNonEmpty(RunWhen = RunWhen.Insert)]
>    public virtual Address Address
>    {
>        get { return address; }
>        set { address = value; }
>    }
>
>    //... other props
> }
>
> [ActiveRecord( Lazy=true, DynamicInsert=true, DynamicUpdate=true,
> SelectBeforeUpdate=true )]
> public class Address : ActiveRecordValidationBase<Address>
> {
>    // all properties are required: street, street nr, city, postcode
>    [Property]
>    [ValidateNonEmpty]
>    public virtual string Street
>    {
>        get { return street; }
>        set { street = value; }
>    }
> }
>
> [Test]
> public void Validate_Incident()
> {
>        Incident i = new Incident();
>        i.Address = new Address();
>
>        CachedValidationRegistry registry = new CachedValidationRegistry();
>        ValidatorRunner runner = new ValidatorRunner( registry );
>
>        bool valid = runner.IsValid( i );
>        Assert.That(valid, Is.False);
> }
>
> The test fails, meaning that the incident is considered valid, even
> though the address (or other props) are not filled in.
> The validation is not performed in the controller either, in a code
> like this:
>
> public void Save( [DataBind( "incident", Validate=true )] Incident
> incident )
> {
>    ...
> }
>
> Am i doing something wrong? Is there a bug? This issue is driving me
> crazy...
>
> Dan
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to