File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66. INPUTS
77 The object to validate.
88. OUTPUTS
9- The validation errors, if any .
9+ `$true` if the validated object is valid, otherwise `$false` .
1010#>
1111function Test-Validation {
1212 [CmdletBinding ()]
13- [OutputType ([hashtable ])]
13+ [OutputType ([bool ])]
1414 param (
1515 # The object to validate.
1616 [Parameter (Mandatory , Position = 1 , ValueFromPipeline )]
@@ -22,18 +22,13 @@ function Test-Validation {
2222 )
2323
2424 process {
25- $errors = @ {}
26-
2725 foreach ($property in $RuleSet.Keys ) {
28- foreach ($item in @ ($RuleSet [$property ])) {
29- $validator = [Validator ] $item
30- if (-not $validator.IsValid ($Object .$property )) {
31- $errors [$property ] = $validator.Reason
32- break
33- }
26+ foreach ($rule in @ ($RuleSet [$property ])) {
27+ $validator = [Validator ] $rule
28+ if (-not $validator.IsValid ($Object .$property )) { return $false }
3429 }
3530 }
3631
37- $errors
32+ $true
3833 }
3934}
You can’t perform that action at this time.
0 commit comments