Title: Why `127.0.0.1` valid and how to validate only cidr notation · Issue #290 · python-validators/validators · GitHub
Open Graph Title: Why `127.0.0.1` valid and how to validate only cidr notation · Issue #290 · python-validators/validators
X Title: Why `127.0.0.1` valid and how to validate only cidr notation · Issue #290 · python-validators/validators
Description: I wrote a cidr validation code like below def ip_address_cidr_validation(value: str) -> bool: """Validate IP address in CIDR notation.""" return bool( validators.ipv4(value, cidr=True, strict=True) or validators.ipv6(value, cidr=True, st...
Open Graph Description: I wrote a cidr validation code like below def ip_address_cidr_validation(value: str) -> bool: """Validate IP address in CIDR notation.""" return bool( validators.ipv4(value, cidr=True, strict=True)...
X Description: I wrote a cidr validation code like below def ip_address_cidr_validation(value: str) -> bool: """Validate IP address in CIDR notation.""" return bool( validators.ip...
Opengraph URL: https://github.com/python-validators/validators/issues/290
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Why `127.0.0.1` valid and how to validate only cidr notation","articleBody":"I wrote a cidr validation code like below\r\n\r\n```python\r\ndef ip_address_cidr_validation(value: str) -\u003e bool:\r\n \"\"\"Validate IP address in CIDR notation.\"\"\"\r\n return bool(\r\n validators.ipv4(value, cidr=True, strict=True)\r\n or validators.ipv6(value, cidr=True, strict=True)\r\n )\r\n```\r\n\r\nwhile there was no problem in older versions, I saw that the following 3 values are \"True\" in the latest version of the library.\r\n\r\nshouldn't the following three ip's be false? it's not \"cidr\"\r\n\r\n2001:0db8:85a3:0000:0000:8a2e:0370:7334 -\u003e False\r\n127.0.0.1 -\u003e False\r\n1.1.1.1/24 -\u003e False\r\n192.0.2.0/255.255.255.0 -\u003e False\r\n\r\nMy test case\r\n\r\n```python\r\n@pytest.mark.parametrize(\r\n (\"cidr\", \"status\"),\r\n [\r\n (\"1.1.1.1/32\", True),\r\n (\"178.251.45.0/24\", True),\r\n (\"2001:0db8:85a3:0000:0000:8a2e:0370:7334/128\", True),\r\n (\"192.0.2.0/255.255.255.0\", False),\r\n (\"192.168.0.0/32\", True),\r\n (\"1.1.1.1/24\", True),\r\n (\"127.0.0.1\", False),\r\n (\"127.0.0.2.4\", False),\r\n (\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\", False),\r\n (\"192.168.0. 1\", False),\r\n (\"192.168.0.1 /32\", False),\r\n ],\r\n)\r\ndef test_ipaddress_cidr_validation_valid(cidr: str, status: bool) -\u003e None:\r\n \"\"\"Ensure the function works correctly when CIDR is entered correctly.\"\"\"\r\n cidr_validator = ip_address_cidr_validation(cidr)\r\n assert cidr_validator is status\r\n```\r\n\r\nHow can this happen? Am I applying this validator incorrectly?","author":{"url":"https://github.com/mertcangokgoz","@type":"Person","name":"mertcangokgoz"},"datePublished":"2023-08-22T22:09:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/290/validators/issues/290"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b42a4ca4-ef92-4f23-6719-7b2bb7351939 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD40:1F7B3F:2FF6D3:3EB7F5:698FAD01 |
| html-safe-nonce | 04fd7a08751c97c9af2d07f10126e5650e8cc587589b9593a65e142deba345c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDQwOjFGN0IzRjoyRkY2RDM6M0VCN0Y1OjY5OEZBRDAxIiwidmlzaXRvcl9pZCI6Ijg0OTc0MzA5MDY3MDQ3MzU0ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1fdbc451cc191ead3d8037fb67d82ecf83fb35301f2a6014a5afb8aa8a2bd1a3 |
| hovercard-subject-tag | issue:1862271340 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-validators/validators/290/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7cda159c9cbbf28c20e27f84693993a3c9baa8b2d581ad61ffedaace0737f76a/python-validators/validators/issues/290 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7cda159c9cbbf28c20e27f84693993a3c9baa8b2d581ad61ffedaace0737f76a/python-validators/validators/issues/290 |
| og:image:alt | I wrote a cidr validation code like below def ip_address_cidr_validation(value: str) -> bool: """Validate IP address in CIDR notation.""" return bool( validators.ipv4(value, cidr=True, strict=True)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mertcangokgoz |
| hostname | github.com |
| expected-hostname | github.com |
| None | a413d5841601ce811368a757abafd33518c11d9f1b18db7de60f7e4e0da278ae |
| turbo-cache-control | no-preview |
| go-import | github.com/python-validators/validators git https://github.com/python-validators/validators.git |
| octolytics-dimension-user_id | 113113270 |
| octolytics-dimension-user_login | python-validators |
| octolytics-dimension-repository_id | 13642984 |
| octolytics-dimension-repository_nwo | python-validators/validators |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13642984 |
| octolytics-dimension-repository_network_root_nwo | python-validators/validators |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ce13de8048c6fca942478f24a897da4faab6f24d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width