From 9988c11bf4e225eeed244510d259ea56c5948eb1 Mon Sep 17 00:00:00 2001 From: Gabriel Ngandu-biseba Date: Thu, 22 Jun 2023 18:15:14 +0200 Subject: [PATCH 1/4] Add support for min/max length/value for integers and arrays --- src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 | 33 ++++++++++++++++++++ src/PSDocs.Azure/en/PSDocs-strings.psd1 | 4 +++ 2 files changed, 37 insertions(+) diff --git a/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 b/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 index 3fafbd72..d129f95e 100644 --- a/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 +++ b/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 @@ -28,6 +28,19 @@ function global:GetTemplateParameter { if ([bool]$property.Value.PSObject.Properties['allowedValues']) { $result['allowedValues'] = $property.Value.allowedValues; } + if ([bool]$property.Value.PSObject.Properties['minValue']) { + $result['minValue'] = $property.Value.minValue; + } + if ([bool]$property.Value.PSObject.Properties['maxValue']) { + $result['maxValue'] = $property.Value.maxValue; + } + + if ([bool]$property.Value.PSObject.Properties['minLength']) { + $result['minLength'] = $property.Value.minValue; + } + if ([bool]$property.Value.PSObject.Properties['maxLength']) { + $result['maxLength'] = $property.Value.maxValue; + } [PSCustomObject]$result; } } @@ -297,6 +310,26 @@ Document 'README' -With 'Azure.TemplateSchema' { "**$($LocalizedData.AllowedValues)**" $parameter.AllowedValues | Code 'text' } + + if ($Null -ne $parameter.MinValue-and $parameter.MinValue.Length -gt 0) { + "**$($LocalizedData.MinValue)**" + $parameter.MinValue | Code 'text' + } + + if ($Null -ne $parameter.MaxValue-and $parameter.MaxValue.Length -gt 0) { + "**$($LocalizedData.MaxValue)**" + $parameter.MaxValue | Code 'text' + } + + if ($Null -ne $parameter.MinLength-and $parameter.MinLength.Length -gt 0) { + "**$($LocalizedData.MinLength)**" + $parameter.MinLength | Code 'text' + } + + if ($Null -ne $parameter.MaxLength-and $parameter.MaxVLength.Length -gt 0) { + "**$($LocalizedData.MaxLength)**" + $parameter.MaxLength | Code 'text' + } } } } diff --git a/src/PSDocs.Azure/en/PSDocs-strings.psd1 b/src/PSDocs.Azure/en/PSDocs-strings.psd1 index f3a86c39..2a15d023 100644 --- a/src/PSDocs.Azure/en/PSDocs-strings.psd1 +++ b/src/PSDocs.Azure/en/PSDocs-strings.psd1 @@ -17,4 +17,8 @@ Required = 'Required' RequiredYes = 'Yes' RequiredNo = 'No' + MinValue = 'Minimum value' + MaxValue = 'Maximum value' + MinLength = 'Minimum length' + MaxLength = 'Maximum length' } From 28504b56be594bd5d143b9f4626b72d56c71bc86 Mon Sep 17 00:00:00 2001 From: Gabriel Ngandu-biseba Date: Thu, 22 Jun 2023 18:20:55 +0200 Subject: [PATCH 2/4] Adapt test data for the new output --- templates/storage/v1/README.md | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/templates/storage/v1/README.md b/templates/storage/v1/README.md index 89438c9c..8d7ecafd 100644 --- a/templates/storage/v1/README.md +++ b/templates/storage/v1/README.md @@ -74,6 +74,18 @@ Determine how many additional characters are added to the storage account name a 0 ``` +**Minimum value** + +```text +0 +``` + +**Maximum value** + +```text +13 +``` + ### containers ![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square) @@ -98,6 +110,18 @@ The number of days to retain deleted blobs. When set to 0, soft delete is disabl 0 ``` +**Minimum value** + +```text +0 +``` + +**Maximum value** + +```text +365 +``` + ### containerSoftDeleteDays ![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square) @@ -110,6 +134,18 @@ The number of days to retain deleted containers. When set to 0, soft delete is d 0 ``` +**Minimum value** + +```text +0 +``` + +**Maximum value** + +```text +365 +``` + ### shares ![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square) @@ -140,6 +176,18 @@ The number of days to retain deleted shares. When set to 0, soft delete is disab 0 ``` +**Minimum value** + +```text +0 +``` + +**Maximum value** + +```text +365 +``` + ### allowBlobPublicAccess ![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square) From f5c60c07562ad882571ba88289f45957cd0b02e5 Mon Sep 17 00:00:00 2001 From: Gabriel Ngandu-biseba Date: Thu, 22 Jun 2023 18:32:02 +0200 Subject: [PATCH 3/4] Corrects typo and incorrect property reference minValue for $result['minLength'] and maxValue for $result['minLength'] --- src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 b/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 index d129f95e..385c15ab 100644 --- a/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 +++ b/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 @@ -36,10 +36,10 @@ function global:GetTemplateParameter { } if ([bool]$property.Value.PSObject.Properties['minLength']) { - $result['minLength'] = $property.Value.minValue; + $result['minLength'] = $property.Value.minLength; } if ([bool]$property.Value.PSObject.Properties['maxLength']) { - $result['maxLength'] = $property.Value.maxValue; + $result['maxLength'] = $property.Value.maxLength; } [PSCustomObject]$result; } @@ -326,7 +326,7 @@ Document 'README' -With 'Azure.TemplateSchema' { $parameter.MinLength | Code 'text' } - if ($Null -ne $parameter.MaxLength-and $parameter.MaxVLength.Length -gt 0) { + if ($Null -ne $parameter.MaxLength-and $parameter.MaxLength.Length -gt 0) { "**$($LocalizedData.MaxLength)**" $parameter.MaxLength | Code 'text' } From 8ba6bdcee09e2682ee2aef7485f5141e5793e3db Mon Sep 17 00:00:00 2001 From: Gabriel Ngandu-biseba Date: Thu, 22 Jun 2023 18:33:08 +0200 Subject: [PATCH 4/4] Corrects missing space --- src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 b/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 index 385c15ab..0ec9848c 100644 --- a/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 +++ b/src/PSDocs.Azure/docs/Azure.Template.Doc.ps1 @@ -311,22 +311,22 @@ Document 'README' -With 'Azure.TemplateSchema' { $parameter.AllowedValues | Code 'text' } - if ($Null -ne $parameter.MinValue-and $parameter.MinValue.Length -gt 0) { + if ($Null -ne $parameter.MinValue -and $parameter.MinValue.Length -gt 0) { "**$($LocalizedData.MinValue)**" $parameter.MinValue | Code 'text' } - if ($Null -ne $parameter.MaxValue-and $parameter.MaxValue.Length -gt 0) { + if ($Null -ne $parameter.MaxValue -and $parameter.MaxValue.Length -gt 0) { "**$($LocalizedData.MaxValue)**" $parameter.MaxValue | Code 'text' } - if ($Null -ne $parameter.MinLength-and $parameter.MinLength.Length -gt 0) { + if ($Null -ne $parameter.MinLength -and $parameter.MinLength.Length -gt 0) { "**$($LocalizedData.MinLength)**" $parameter.MinLength | Code 'text' } - if ($Null -ne $parameter.MaxLength-and $parameter.MaxLength.Length -gt 0) { + if ($Null -ne $parameter.MaxLength -and $parameter.MaxLength.Length -gt 0) { "**$($LocalizedData.MaxLength)**" $parameter.MaxLength | Code 'text' }