PowerShell classes may be used to build custom validation attributes. This might act as an alternative to ValidateScript in some respects.
Validation attributes must inherit from either ValidateArgumentsAttribute or ValidateEnumeratedArgumentsAttribute.
Validators are most often used with parameters in scripts and functions, but they may be used with any variable.