Added validation code and examples.