| 8 | } |
| 9 | |
| 10 | export const validateIPorCIDR = (rule, value) => { |
| 11 | if (!value) { |
| 12 | return Promise.resolve() |
| 13 | } |
| 14 | |
| 15 | const lines = value.split('\n') |
| 16 | const ipCidrRegex = |
| 17 | /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[1-2][0-9]|3[0-2]))?$/ |
| 18 | |
| 19 | for (const line of lines) { |
| 20 | if (line && !ipCidrRegex.test(line.trim())) { |
| 21 | return Promise.reject($t('输入的IP或CIDR不符合格式')) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | return Promise.resolve() |
| 26 | } |
| 27 | |
| 28 | export const validateApiPath = (rule, value) => { |
| 29 | if (!value) { |