-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
I'd like to propose adding a ValidateProperties attribute which would make it easier to validate that an incoming object had specific properties.
Hypothetically, use of it might look something like this:
[Parameter()]
[ValidateProperty(@{ SourceFile = [string]}, @{SourceLineNumber = [int]})]
[PSObject]$InputObjectThe idea being that this would ensure that the InputObject has a SourceFile property of type string and a SourceLineNumber property of type int ...
Or you might even just do:
[Parameter()]
[ValidateProperty("SourceFile", "SourceLineNumber")]
[PSObject]$InputObjectWhich would just validate the properties exist, and not their types.
We might even extend it with a NotNullOrEmpty check ...
Obviously I can add this in an external module, and I can do this validation with a ValidateScript ... but it seems like something that's generally useful (along the lines of the [PSTypeName()] attribute, but with the focus being on the shape of the object, rather than the name.
Thoughts?