i'm trying to learn EnterpriseLibraryValidatoin. when i configure TypeValidation to validate a class through config file it does not pick up. but when i add Data Annotations it Validates Correctly I don't know if i'm leaving something out
any help please
validation config file
<validation>
<type name="ValidationBlockExample.Person" defaultRuleset="ValidimiFushave"
assemblyName="ValidationBlockExample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<ruleset name="ValidimiFushave">
<fields>
<field name="LastName">
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
messageTemplate="Last Name Required!" name="Not Null Validator" />
</field>
</fields>
</ruleset>
</type>
code to validate
ValidationFactory.SetDefaultConfigurationValidatorFactory(new SystemConfigurationSource(false));
Validator<Person> pValidator = ValidationFactory.CreateValidator<Person>();
Person prsn = new Person();
prsn.FirstName = "Name";
////prsn.LastName = "Haz";
prsn.Age = 31;
ValidationResults valResults = pValidator.Validate(prsn);
if (!valResults.IsValid)
{
foreach (var valResult in valResults)
{
Console.WriteLine(valResult.Message);
}
}
else
Console.WriteLine("Preson Validated !!!");
Console.ReadLine();
the class to be validated
public class Person
{
public string FirstName { get; set; }
//[Required]
public string LastName { get; set; }
public int Age { get; set; }
}