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

URL validation fails for file:/// #1165

Open
2 tasks done
pklanka opened this issue Sep 14, 2023 · 1 comment
Open
2 tasks done

URL validation fails for file:/// #1165

pklanka opened this issue Sep 14, 2023 · 1 comment

Comments

@pklanka
Copy link

pklanka commented Sep 14, 2023

  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10: v10

Issue, Question or Enhancement: Issue

Code sample, to showcase or reproduce:

package main

import (
	"fmt"

	"github.com/go-playground/validator/v10"
)

type SampleStruct struct {
	FileUrl string `json:"file_url" validate:"omitempty,url"`
}

func main() {

	Validator := validator.New()
	sample := SampleStruct{
		FileUrl: "file://tmp/abcd",
	}
	if err := Validator.Struct(sample); err != nil {
		// this passes
		fmt.Println(err)
	}

	sample2 := SampleStruct{
		FileUrl: "file:///tmp/abcd",
	}
	if err := Validator.Struct(sample2); err != nil {
		// this fails
		fmt.Println(err)
	}
}
@pklanka pklanka changed the title URL fails for file:/// URL validation fails for file:/// Sep 14, 2023
@pklanka
Copy link
Author

pklanka commented Sep 14, 2023

file:///tmp/abcd should a valid file URL - ref: https://jkorpela.fi/fileurl.html

deankarn pushed a commit that referenced this issue Nov 4, 2023
## Fixes Or Enhances

This PR adds an additional check for the file URL schema.
Connected to #1165

**Make sure that you've checked the boxes below before you submit PR:**
- [x] Tests exist or have been written that cover this particular
change.

@go-playground/validator-maintainers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant