locked
Validation errors are not popping while using the custom validator in dataform RRS feed

  • Question

  • Hi,

    I have a dataform where i would like to use the validations feature provided by it by using domain services classes. below is the code i have used to do this but the validation error never pops.

    [CustomValidation(typeof(PMS2.Web.Services.Validator), "IsKRACatValid",ErrorMessage="Invalid KRA")]

    public static class Validator

    {

    public static ValidationResult IsKRACatValid(string category,ValidationContext context)

    {

    ValidationResult result = null;if (category.ToLower().Equals("functional") || category.ToLower().Equals("behavirol"))

    {

    result =
    ValidationResult.Success;

    }

    else

    {

    result =
    new ValidationResult("Category can be Functional or Behavirol");

    }

    return result;

    }

    }

     

    is there any thing that i need to add more to get the errors up when i click 'OK' in the dataform's edit mode?

    Thanks

    Monday, September 7, 2009 9:10 AM

Answers

All replies

  • You should decorate your entity property with the CustomValidationAttribute, not the validator class.

    Tuesday, September 8, 2009 2:50 AM
  • The 'Validator' class in the above code is the class that is holding my custom validation techniques. and the first line is the way i have used the Validator calss in the context of custom validation.

    Its compiled successfully and working very well,say in the debug mode. but it never shows the error at UI. any extra stuff to be done on this?

    thanks

    Tuesday, September 8, 2009 12:38 PM
  • It should work they way you have implemented it. It works fine in my demo in combination with a DataForm. Maybe another validation constraint is broken earlier? Try to add a simple string length constraint to see if you will see that one in the screen...

    Tuesday, September 8, 2009 1:08 PM
  • Hi Rkapisetti,

    You'd better reference to RIAServicesOverviewPreview.pdf.   There is a pretty good sample.  You can find the sample on page 94.  Thanks.

    Best regards,

    Jonathan

     

     

    Friday, September 11, 2009 6:37 AM