Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Support CIDR notation in IsIP validator #727

Open
grimurd opened this issue Aug 26, 2020 · 1 comment · May be fixed by #2269
Open

feature: Support CIDR notation in IsIP validator #727

grimurd opened this issue Aug 26, 2020 · 1 comment · May be fixed by #2269
Labels
type: feature Issues related to new features.

Comments

@grimurd
Copy link

grimurd commented Aug 26, 2020

Description

Currently the IP validation fails when a IP subnet using CIDR notation is given.

Example values

  • 192.168.1.1/32
  • 2001:db8::/32

Proposed solution

Add an additional argument to the IsIP validator specifying whether CIDR notation is required, optional or forbidden. Default the argument to forbidden to maintain backwards compatibility.

Optionally the CIDR prefix could be validated. It can only have value 0-32 for IPv4 or 0-128 for IPv6

@Kiliandeca
Copy link
Contributor

Hi, we use validator.js internally and they seem to have a isIPRange() validator but it haven't been imported to class-validator yet. Feel free to open a PR

It only support ipv4 so you would also have to open an issue there to ask a feature request for IPv6 range

@Kiliandeca Kiliandeca added the type: feature Issues related to new features. label Aug 27, 2020
AnandChowdhary added a commit to AnandChowdhary/class-validator that referenced this issue Jan 1, 2021
AnandChowdhary added a commit to AnandChowdhary/class-validator that referenced this issue Jan 1, 2021
ballinette pushed a commit to ballinette/class-validator that referenced this issue Oct 6, 2023
ballinette pushed a commit to ballinette/class-validator that referenced this issue Oct 6, 2023
ballinette pushed a commit to ballinette/class-validator that referenced this issue Oct 6, 2023
ballinette pushed a commit to ballinette/class-validator that referenced this issue Oct 6, 2023
@ballinette ballinette linked a pull request Oct 6, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Issues related to new features.
Development

Successfully merging a pull request may close this issue.

2 participants