Hello Maurico,

Good answer, thanks.

I guess the change is simple anyway, so if I ever really needed error
codes I can always deploy my own version.

regards,
Jordan.



On Aug 10, 9:52 pm, Mauricio Scheffer <[email protected]>
wrote:
> IMHO this is not a good idea. An error code (int/float/double) is just
> as "magic" as a string. Replacing a string with an int doesn't really
> achieve anything, and you'll have another problem because you'll
> probably need a lookup table int -> message.
>
> Remember that you can extract the message as a const, e.g.:
>
> const string ValidateMailMessage = "This is an invalid email";
> [ValidateEmail(ValidateMailMessage)] string Email {get;set;}
>
> This way you can easily match the message in your tests.
>
> Furthermore, Castle Validator can use .net resources to look up
> validation messages (ErrorMessageKey property in validation
> attribute).
>
> Even more, Castle Validator can be used without attributes if you want
> true POCOs in your domain. Just implement IValidatorRegistry.
>
> --
> Mauricio
>
> On Tue, Aug 10, 2010 at 7:57 AM, Jordan Muscott
>
> <[email protected]> wrote:
> > Hello all,
>
> > I'm playing around with adding an error code named parameter to Castle
> > validator attributes. I'm doing this because:
>
> > 1) When writing unit tests sometimes it seems ugly to match a string
> > to find out what error was called.
> > 2) If you are writing some code which needs to be reusable (eg it
> > might be used in a batch process) then just setting an error message
> > might not be what you need. The process might need to check the error
> > code and then act accordingly (eg exit).
> > 3) If you were being very picky you could argue that the domain layer
> > should not be setting error messages anway.
>
> > Would anyone be interested in this?
> > If so any preference on error code type (ie, int, float, double).
>
> > regards,
> > Jordan.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Castle Project Development List" 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 
> > athttp://groups.google.com/group/castle-project-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

Reply via email to