title: Java - Designing a validator, class hierarchy
body: <p>I'm working on designing a validator for certain objects (fields of those objects). These objects are enclosed in one, bigger object - container.</p>
  
  <p>Example: Car as a container . Consists of Wheels, Engine, Body.
  Lets say i need to validate if wheels have correct diameter, engine has correct capacity, body has certain length etc.</p>
  
  <p>Theoretically I think I should validate everything before construction of a container (car).</p>
  
  <p>What is the best way to achieve this? Do I make an abstract validator class with validate() method and implement it in every enclosed class? What about the container, do I just not include it at all in the validation process? Thanks for help.</p>