Added support for custom validation via closure.