You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "DaanHoogland (via GitHub)" <gi...@apache.org> on 2025/11/12 13:23:13 UTC

Re: [PR] ui,api: support secondary staging store actions [cloudstack]

DaanHoogland commented on code in PR #11381:
URL: https://github.com/apache/cloudstack/pull/11381#discussion_r2518294667


##########
ui/src/utils/util.js:
##########
@@ -103,6 +103,27 @@ 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])$/
+    if (!cidrRegex.test(value)) {
+      reject(new Error('Invalid CIDR format'))
+      return
+    }
+    const ip = value.split('/')[0]
+    const octets = ip.split('.').map(Number)
+    if (octets.some(octet => octet < 0 || octet > 255)) {
+      reject(new Error('Invalid CIDR format'))
+      return
+    }
+    resolve()
+  })
+}
+
 export function getSingularIfPluralWord(word) {

Review Comment:
   ```suggestion
   export function getSingularIfPluralWord (word) {
   ```



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org