Just as an aside Validators don't work on nested objects either, which
pretty much means nested objects are useless...
e.g.
[ActiveRecord]
public class Incident
{
....
[Nested]
public Address Address
{ ... }
}
public class Address
{
[Property, ValidateNotEmpty]
public string Steet
{ ... }
}
if you call .Validate on Incident the validator for
Incident.Address.Street will not be called.
On Jul 28, 8:25 am, bdaniel7 <[email protected]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---