Copilot commented on code in PR #11465:
URL: https://github.com/apache/cloudstack/pull/11465#discussion_r2425306348
##########
ui/src/utils/util.js:
##########
@@ -102,3 +102,24 @@ export function toCsv ({ keys = null, data = null,
columnDelimiter = ',', lineDe
return result
}
+
+export function isValidIPv4Cidr (rule, value) {
+ return new Promise((resolve, reject) => {
+ if (!value) {
+ reject(new Error())
Review Comment:
The error message for the empty value case is missing. When `value` is
falsy, the rejection should include a descriptive error message like 'CIDR
value is required' to help users understand what went wrong.
```suggestion
reject(new Error('CIDR value is required'))
```
##########
ui/src/utils/util.js:
##########
@@ -102,3 +102,24 @@ export function toCsv ({ keys = null, data = null,
columnDelimiter = ',', lineDe
return result
}
+
+export function isValidIPv4Cidr (rule, value) {
+ return new Promise((resolve, reject) => {
+ if (!value) {
+ reject(new Error())
+ return
+ }
+ const cidrRegex = /^(\d{1,3}\.){3}\d{1,3}\/([0-9]|[1-2][0-9]|3[0-2])$/
Review Comment:
The CIDR regex allows prefix lengths from 0 to 32, but a prefix length of 0
would represent the entire IPv4 address space (0.0.0.0/0) which may not be
appropriate for VPC creation. Consider if the minimum prefix length should be
restricted (e.g., starting from /8 or /16) based on VPC requirements.
```suggestion
const cidrRegex = /^(\d{1,3}\.){3}\d{1,3}\/([8-9]|[1-2][0-9]|3[0-2])$/
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]