classes
On Mon, Jan 31, 2011 at 6:55 PM, Berryl Hesh <[email protected]> wrote:
> I have two related ValidDef<T> classes, one for a FullName, and one
> for an Employee which has a FullName. I can't seem to say IsValid
> loquaciously. I am using v1.3.0.2001, and I can access the
> ValidAttribute.
>
> The code is below
>
> Cheers,
> Berryl
>
> public class FullNameValidator : ValidationDef<FullName>
> {
> public FullNameValidator() {
>
> Define(n =>
> n.FirstName).NotNullable().And.NotEmpty().And.MaxLength(25);
> Define(n =>
> n.LastName).NotNullable().And.NotEmpty().And.MaxLength(35);
>
> // this is likely not necessary, but am not sure yet
> ValidateInstance
> .By(
> (name, context) => !
> name.FirstName.IsNullOrEmptyAfterTrim() && !
> name.LastName.IsNullOrEmptyAfterTrim())
> .WithMessage("Both a First and Last Name are
> required");
> }
> }
>
> public class EmployeeValidator : ValidationDef<Employee>
> {
> public EmployeeValidator()
> {
>
> Define(x => x.FullName).IsValid(); <<<<<<<<<< This will
> not compile
>
> Define(x => x.Department).NotNullable();
>
> Define(x => x.EmployeeNumber).NotNullable();
> }
> }
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
--
Fabio Maulo
--
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.