ipv4 validation not implemented
See original GitHub issueGeneral information
The ipv4 format specifies that the entered string should be in the format of an ipv4 address. I believe this was already specified in json schema v4 but doesn’t seem to be implemented in json-editor.
- json-editor version: 1.4.0-beta.0
Expected behavior
Should create a validation error if a non-valid ip address is entered into a string field specified with format ipv4.
Actual behavior
Does not raise a validation error.
Steps to reproduce the behavior
{
"title": "json schema example",
"type": "object",
"properties": {
"ipAddress": {
"type": "string",
"format": "ipv4",
"description": "IP address."
}
},
"required": [
"ipAddress"
]
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
How do you validate that a string is a valid IPv4 address in C++?
WARNING. According to the docs, it returns -1 for invalid AF argument, 0 for invalid address, and +1 for valid IP address. – ......
Read more >[Feature Request] validation IP address (at least IPv4) #628
or maybe even implement some (weird) extra code like what I've seen here on a project I'm working on: let ipAddressSchema = Yup.string()...
Read more >Program to validate an IP address - GeeksforGeeks
Following are steps to check whether a given string is a valid IPv4 address or not: step 1) Parse string with “.
Read more >Validate IP Address - LeetCode
Given a string queryIP , return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or...
Read more >How To Validate an IP Address with Python (2022) | AbstractAPI
The ipaddress module is not actually validating our IP address. It's attempting to use the provided string to create a Python IP address ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wrote a custom validator below that will provide this validation. Would you like me to attempt to create a PR to include make it part of the default validation?
@sirockin Good idea, as both ipv4 and ipv6 is part of the 04 specs. https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-7.3.4 So the validation should support both versions. Also it might also be a good idea to create an “ip editor”. It just has to extend the “string” editor and set a validator pattern, similar to what I did in the UUID editor
postBuild()
function. https://github.com/json-editor/json-editor/blob/master/src/editors/uuid.jsIPv4 Regex pattern:
^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$
IPv6 Regex pattern:^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$
You can also find a lot of “ip” regex patterns here: https://regex101.com/library?orderBy=RELEVANCE&search=ip