Skip to content

Commit b819e33

Browse files
committed
Updating Help docs, updating psscriptanalyzer results
1 parent 1a8a4a3 commit b819e33

9 files changed

Lines changed: 177 additions & 98 deletions

File tree

PSFluentObjectValidation/Private/PSFluentObjectValidation.ps1

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static class PSFluentObjectValidation
4848
WildcardArrayWrapper wrapper = (WildcardArrayWrapper)currentObject;
4949
return ProcessWildcardPropertyAccess(wrapper.ArrayObject, part);
5050
}
51-
51+
5252
// Check for array indexing: property[index] or property[*]
5353
Match arrayMatch = ArrayIndexPattern.Match(part);
5454
if (arrayMatch.Success)
@@ -232,13 +232,13 @@ public static class PSFluentObjectValidation
232232
233233
private static object ProcessWildcardPropertyAccess(object arrayObject, string propertyName)
234234
{
235-
// First check if this is an array indexing pattern: property[index] or property[*]
235+
// First check if this is an array indexing pattern: property[index] or property[*]
236236
Match arrayMatch = ArrayIndexPattern.Match(propertyName);
237237
if (arrayMatch.Success)
238238
{
239239
string basePropertyName = arrayMatch.Groups[1].Value;
240240
string indexStr = arrayMatch.Groups[2].Value;
241-
241+
242242
// Handle array indexing after wildcard: items[0], tags[*], etc.
243243
if (arrayObject is Array)
244244
{
@@ -248,21 +248,21 @@ public static class PSFluentObjectValidation
248248
object element = array.GetValue(i);
249249
if (element == null)
250250
throw new InvalidOperationException(String.Format("Array element [{0}] is null", i));
251-
251+
252252
if (!HasProperty(element, basePropertyName))
253253
throw new InvalidOperationException(String.Format("Array element [{0}] does not have property '{1}'", i, basePropertyName));
254-
254+
255255
object propertyValue = GetProperty(element, basePropertyName);
256256
if (propertyValue == null)
257257
throw new InvalidOperationException(String.Format("Property '{0}' in element [{1}] is null", basePropertyName, i));
258258
if (!IsArrayLike(propertyValue))
259259
throw new InvalidOperationException(String.Format("Property '{0}' in element [{1}] is not an array", basePropertyName, i));
260260
}
261-
261+
262262
// All elements are valid, now handle the indexing
263263
object firstElement = array.GetValue(0);
264264
object firstPropertyValue = GetProperty(firstElement, basePropertyName);
265-
265+
266266
if (indexStr == "*")
267267
{
268268
return new WildcardArrayWrapper(firstPropertyValue);
@@ -273,7 +273,7 @@ public static class PSFluentObjectValidation
273273
int count = GetCount(firstPropertyValue);
274274
if (index < 0 || index >= count)
275275
throw new InvalidOperationException(String.Format("Array index [{0}] is out of bounds for property '{1}' (length: {2})", index, basePropertyName, count));
276-
276+
277277
if (firstPropertyValue is Array)
278278
{
279279
Array firstArray = (Array)firstPropertyValue;
@@ -286,7 +286,7 @@ public static class PSFluentObjectValidation
286286
}
287287
}
288288
}
289-
289+
290290
if (arrayObject is IList)
291291
{
292292
IList list = (IList)arrayObject;
@@ -297,18 +297,18 @@ public static class PSFluentObjectValidation
297297
throw new InvalidOperationException(String.Format("Array element [{0}] is null", i));
298298
if (!HasProperty(element, basePropertyName))
299299
throw new InvalidOperationException(String.Format("Array element [{0}] does not have property '{1}'", i, basePropertyName));
300-
300+
301301
object propertyValue = GetProperty(element, basePropertyName);
302302
if (propertyValue == null)
303303
throw new InvalidOperationException(String.Format("Property '{0}' in element [{1}] is null", basePropertyName, i));
304304
if (!IsArrayLike(propertyValue))
305305
throw new InvalidOperationException(String.Format("Property '{0}' in element [{1}] is not an array", basePropertyName, i));
306306
}
307-
307+
308308
// All elements are valid, now handle the indexing
309309
object firstElement = list[0];
310310
object firstPropertyValue = GetProperty(firstElement, basePropertyName);
311-
311+
312312
if (indexStr == "*")
313313
{
314314
return new WildcardArrayWrapper(firstPropertyValue);
@@ -319,7 +319,7 @@ public static class PSFluentObjectValidation
319319
int count = GetCount(firstPropertyValue);
320320
if (index < 0 || index >= count)
321321
throw new InvalidOperationException(String.Format("Array index [{0}] is out of bounds for property '{1}' (length: {2})", index, basePropertyName, count));
322-
322+
323323
if (firstPropertyValue is Array)
324324
{
325325
Array firstArray = (Array)firstPropertyValue;
@@ -332,7 +332,7 @@ public static class PSFluentObjectValidation
332332
}
333333
}
334334
}
335-
335+
336336
throw new InvalidOperationException(String.Format("Cannot process wildcard array indexing on type {0}", arrayObject.GetType().Name));
337337
}
338338

PSFluentObjectValidation/Public/Assert-Exist.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ The property path to validate. Supports fluent syntax with validation operators:
1717
- `array[*]` - Wildcard validation (all elements must pass)
1818
1919
.EXAMPLE
20-
# Validate that the `user.name` property exists and is non-empty
2120
Assert-Exist -InputObject $data -Key "user.name!"
2221
22+
Asserts that the `user.name` property exists and is non-empty
2323
.EXAMPLE
24-
# Validate that all users in the array have a non-empty email
2524
Assert-Exist -InputObject $data -Key "users[*].email!"
2625
26+
Asserts that all users in the array have a non-empty email
2727
.EXAMPLE
28-
# Validate that the `settings.theme` property exists
2928
Assert-Exist -InputObject $data -Key "settings.theme"
3029
30+
Asserts that the `settings.theme` property exists
3131
.NOTES
3232
Throws an exception if the validation fails. Use `Test-Exist` for a non-throwing alternative.
3333
@@ -44,7 +44,11 @@ function Assert-Exist {
4444
[string]$Key
4545
)
4646

47-
[PSFluentObjectValidation]::AssertExists($InputObject, $Key)
47+
Begin { }
48+
49+
Process {
50+
[PSFluentObjectValidation]::AssertExists($InputObject, $Key)
51+
}
4852
}
4953

5054
New-Alias -Name asserts -Value Assert-Exist

PSFluentObjectValidation/Public/Test-Exist.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ The property path to validate. Supports fluent syntax with validation operators:
1717
- `array[*]` - Wildcard validation (all elements must pass)
1818
1919
.EXAMPLE
20-
# Test if the `user.name` property exists and is non-empty
2120
Test-Exist -InputObject $data -Key "user.name!"
2221
22+
Tests that the `user.name` property exists and is non-empty.
2323
.EXAMPLE
24-
# Test if all users in the array have a non-empty email
2524
Test-Exist -InputObject $data -Key "users[*].email!"
2625
26+
Tests that all users in the array have a non-empty email.
2727
.EXAMPLE
28-
# Test if the `settings.theme` property exists
2928
Test-Exist -InputObject $data -Key "settings.theme"
3029
30+
Tests that the `settings.theme` property exists.
3131
.NOTES
3232
Returns `$true` if the validation passes, `$false` otherwise. Use `Assert-Exist` for a throwing alternative.
3333
@@ -44,7 +44,10 @@ Function Test-Exist {
4444
[string]$Key
4545
)
4646

47-
return [PSFluentObjectValidation]::TestExists($InputObject, $Key)
47+
Begin { }
48+
Process {
49+
return [PSFluentObjectValidation]::TestExists($InputObject, $Key)
50+
}
4851
}
4952

5053
New-Alias -Name exists -Value Test-Exist

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
**PSGallery**
88

9-
[![PowerShell Gallery][psgallery-badge]][psgallery] [![PSGallery Version][psgallery-version-badge]][psgallery]
9+
[![PowerShell Gallery][psgallery-badge]][psgallery] [![PSGallery Version][psgallery-version-badge]][psgallery] [![PSGallery Playform][psgallery-platform-badge]][psgallery] [![PSGallery Playform][ps-desktop-badge]][psgallery]
1010

1111
## General Overview
1212

@@ -223,3 +223,6 @@ Assert-Exist -In $data -With "users[*].phone!" # Throws if ANY user
223223
[github-closed-issues-badge]: https://img.shields.io/github/issues-closed/pwshdevs/PSFluentObjectValidation?style=for-the-badge
224224
[github-closed-issues]: https://github.com/pwshdevs/PSFluentObjectValidation/issues?q=is%3Aissue%20state%3Aclosed
225225
[github-open-issues]: https://github.com/pwshdevs/PSFluentObjectValidation/issues
226+
[psgallery-platform-badge]: https://img.shields.io/powershellgallery/p/PSFluentObjectValidation?style=for-the-badge
227+
[ps-desktop-badge]: https://img.shields.io/badge/powershell-5.1,_7.0+-blue?style=for-the-badge
228+
[ps-core-badge]: https://img.shields.io/badge/powershell-5.1,_7.0+-blue?style=for-the-badge

docs/en-US/Assert-Exist.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@ If the validation fails, it throws a detailed exception, making it suitable for
2424

2525
### EXAMPLE 1
2626
```
27-
# Validate that the `user.name` property exists and is non-empty
2827
Assert-Exist -InputObject $data -Key "user.name!"
2928
```
3029

30+
Asserts that the \`user.name\` property exists and is non-empty
31+
3132
### EXAMPLE 2
3233
```
33-
# Validate that all users in the array have a non-empty email
3434
Assert-Exist -InputObject $data -Key "users[*].email!"
3535
```
3636

37+
Asserts that all users in the array have a non-empty email
38+
3739
### EXAMPLE 3
3840
```
39-
# Validate that the `settings.theme` property exists
4041
Assert-Exist -InputObject $data -Key "settings.theme"
4142
```
4243

44+
Asserts that the \`settings.theme\` property exists
45+
4346
## PARAMETERS
4447

4548
### -InputObject

docs/en-US/Test-Exist.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@ Unlike \`Assert-Exist\`, this function does not throw exceptions; instead, it re
2424

2525
### EXAMPLE 1
2626
```
27-
# Test if the `user.name` property exists and is non-empty
2827
Test-Exist -InputObject $data -Key "user.name!"
2928
```
3029

30+
Tests that the \`user.name\` property exists and is non-empty.
31+
3132
### EXAMPLE 2
3233
```
33-
# Test if all users in the array have a non-empty email
3434
Test-Exist -InputObject $data -Key "users[*].email!"
3535
```
3636

37+
Tests that all users in the array have a non-empty email.
38+
3739
### EXAMPLE 3
3840
```
39-
# Test if the `settings.theme` property exists
4041
Test-Exist -InputObject $data -Key "settings.theme"
4142
```
4243

44+
Tests that the \`settings.theme\` property exists.
45+
4346
## PARAMETERS
4447

4548
### -InputObject

docs/en-US/about_PSFluentObjectValidation.help.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)