alex in a nutshell

November 14, 2007

Creating business objects validation with Enterprise Library Validation Block

Filed under: — Alex Salamakha @ 11:01 PM

I’ve been using MS Enterprise Library on a number of projects. There are several blocks that used more often than others. I find validation block particularly useful. However, I usually like to tweak it a bit. The thing I don’t like is when you want to validate an object you require to write a substantial amount of code:

Validator<Customer> validator = ValidationFactory.CreateValidator<Customer>();

ValidationResults results = validator.Validate(customer);

Also it’s possible to create a validator for another type and validate an object with it without any problems, errors or exceptions:

Validator<WRONGCLASS> validator = ValidationFactory.CreateValidator<WRONGCLASS>();

ValidationResults results = validator.Validate(customer);

This feature is for flexibility, however, I haven’t found a need to use it the way it was intended. On the other hand I have encountered a number of situations where developers copy-pasted code responsible for creation of a validator without changing the type of a target object. This results unexpected behaviour during testing.
In order to fix this every business object is derived from a common parent BaseBusinessObject class, which has the following method defined:

public ValidationResults Validate()

{

Validator validator = ValidationFactory.CreateValidator(this.GetType());

return validator.Validate(this);

}

As a result, validating an object is now a lot simpler:

customer.Validate();

Usually it makes sense to have a base business object class anyway, so it’s not much of an overhead.

42 Comments »

  1. tips to sell your home

    blog topic

    Trackback by tips to sell your home — March 26, 2021 @ 11:53 PM

  2. gucci crossbody bags

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by gucci crossbody bags — January 16, 2022 @ 9:12 AM

  3. periodic table of elements wallpaper 1920×1080

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by periodic table of elements wallpaper 1920x1080 — January 16, 2022 @ 11:12 AM

  4. Biteandswitch`s recent blog post

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by Biteandswitch`s recent blog post — January 16, 2022 @ 12:42 PM

  5. try kirmes-werkel.de

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by try kirmes-werkel.de — January 16, 2022 @ 12:50 PM

  6. asian movies watch online

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by asian movies watch online — January 16, 2022 @ 5:43 PM

  7. hatsan break barrel air rifles

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by hatsan break barrel air rifles — January 16, 2022 @ 7:33 PM

  8. mcm handbags

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by mcm handbags — January 16, 2022 @ 8:36 PM

  9. find more

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by find more — January 16, 2022 @ 10:42 PM

  10. handbags on sale

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by handbags on sale — January 17, 2022 @ 10:14 PM

  11. artego blooming elixir

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by artego blooming elixir — January 18, 2022 @ 5:15 AM

  12. best sex toys for couples

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by best sex toys for couples — January 18, 2022 @ 9:49 AM

  13. small black leather wallet

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by small black leather wallet — January 18, 2022 @ 11:59 AM

  14. Portland Leather Tote

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by Portland Leather Tote — January 18, 2022 @ 12:47 PM

  15. ego 15″ string Trimmer

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by ego 15" string Trimmer — January 18, 2022 @ 2:41 PM

  16. disney princess style collection travel tote

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by disney princess style collection travel tote — January 19, 2022 @ 2:09 AM

  17. husqvarna 141 Chainsaw

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by husqvarna 141 Chainsaw — January 19, 2022 @ 2:14 AM

  18. building blocks toys

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by building blocks toys — January 19, 2022 @ 3:13 PM

  19. Knights Of the round table wallpaper

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by Knights Of the round table wallpaper — January 19, 2022 @ 6:13 PM

  20. valentino garavani rockstud top handle shoulder bag

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by valentino garavani rockstud top handle shoulder bag — January 19, 2022 @ 7:03 PM

  21. source website

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by source website — January 20, 2022 @ 6:45 AM

  22. masai women’s clothing

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by masai women's clothing — January 20, 2022 @ 11:07 AM

  23. mens small Leather wallet

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by mens small Leather wallet — January 20, 2022 @ 4:21 PM

  24. interruttore tapparelle elettriche

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by interruttore tapparelle elettriche — January 21, 2022 @ 5:22 AM

  25. building toys for kids

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by building toys for kids — January 21, 2022 @ 2:11 PM

  26. artego colori per capelli

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by artego colori per capelli — January 22, 2022 @ 8:36 AM

  27. swiss diver watches

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by swiss diver watches — January 22, 2022 @ 9:14 AM

  28. root zte x500 without computer

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by root zte x500 without computer — January 22, 2022 @ 5:55 PM

  29. makita angle grinder ga4530

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by makita angle grinder ga4530 — January 22, 2022 @ 8:30 PM

  30. try this website

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by try this website — January 23, 2022 @ 6:04 PM

  31. Check This Out

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by Check This Out — January 24, 2022 @ 12:07 AM

  32. Michael Michael Kors Saffiano Medium Travel Tote

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by Michael Michael Kors Saffiano Medium Travel Tote — January 24, 2022 @ 9:17 AM

  33. buy hatsan air rifles

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by buy hatsan air rifles — January 24, 2022 @ 12:18 PM

  34. deliveryglasgow.co.uk published a blog post

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by deliveryglasgow.co.uk published a blog post — January 24, 2022 @ 3:15 PM

  35. plastic wallpaper table

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by plastic wallpaper table — January 25, 2022 @ 10:35 PM

  36. 4 inch digital caliper

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by 4 inch digital caliper — January 25, 2022 @ 10:37 PM

  37. mitutoyo 8 digital caliper

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by mitutoyo 8 digital caliper — January 26, 2022 @ 12:00 PM

  38. Recommended Browsing

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by Recommended Browsing — January 26, 2022 @ 12:49 PM

  39. reviews over at Spanning Boundaries

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by reviews over at Spanning Boundaries — January 30, 2022 @ 4:29 AM

  40. smart switch iphone

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by smart switch iphone — January 30, 2022 @ 1:49 PM

  41. alexander mcqueen small pebbled leather satchel

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by alexander mcqueen small pebbled leather satchel — January 30, 2022 @ 3:35 PM

  42. relevant resource site

    Alex in a nutshell » Creating business objects validation with Enterprise Library Validation Block

    Trackback by relevant resource site — January 31, 2022 @ 7:12 AM

RSS feed for comments on this post. TrackBack URL

Leave a comment

Copyright © 1997-2017 Alexei Salamakha. All rights reserved
email: alex@salamakha.com    Alex Salamakha on Facebook    Alex Salamakha on LinkedIn