Object property validator

Topics: Developer Forum, User Forum
Apr 2, 2009 at 3:05 PM
Edited Apr 2, 2009 at 3:08 PM
Hi,

I have something like this:

public class myclass1
{
[ValidationFramework.RequiredStringRule()]
public string MyString
{ get; set;}

// trivial property
public IsValid
{ get { return true;} }
}

public class myclass2
{
[ValidationFramework.RequiredObjectRule()]
public myclass1 TheClass
{ get; set;}
}


I want that the property TheClass is valid when is not null and also if  TheClass.IsValid is == true;

for the check if isn't null I use [ValidationFramework.RequiredObjectRule()]
what I have to use for TheClass.IsValid == true ?

sorry for my english

thanks
Coordinator
Apr 8, 2009 at 1:44 PM
You should use the validatable rule:

public class myclass2
{
[ValidationFramework.ValidatableRule()]
public myclass1 TheClass
{ get; set;}
}

Sorry for the delayed response, I was in DC for a few days.
Apr 9, 2009 at 8:58 AM
thank you very much for reply.

I have another question.

I have to implement always IValidatable interface.
Could  I insert in myclass1 only the property "public bool IsValid" without implement IValidatable in the class ?

thanks.
Apr 9, 2009 at 8:58 AM
thank you very much for reply.

I have another question.

I have to implement always IValidatable interface.
Could  I insert in myclass1 only the property "public bool IsValid" without implement IValidatable in the class ?

thanks.
Coordinator
Apr 9, 2009 at 1:38 PM
You don't have to implement IValidatable. The BusinessBase classes, such as ValidatableBase and IValidatable, are merely usable examples. The framework is not dependent on the use of these to function. This was made clearer for future releases by sperating the businessbase classes into thier own project. I suspect, like you, most people will not want thier model structure dependent on some 3rd framework. Our goal is to make this as light wieght as possible.