validator icon indicating copy to clipboard operation
validator copied to clipboard

Make `url` and `http_url` work with url.URL.

Open bfabio opened this issue 1 year ago • 4 comments

Fixes Or Enhances

This makes the url and http_url validations work with url.URL or any newtype that implements the Stringer interface. I'm not familiar with the codebase so it's kind of a PoC PR to see if you think this can be useful.

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.

But they don't pass, if this is a feature we want and it's the right approach I can investigate deeper. I suspect the reflection magic isn't working as I expected.

@go-playground/validator-maintainers

bfabio avatar Feb 14 '24 13:02 bfabio

I've added a few comments suggesting readability improvements. I recommend keeping the original test functions unchanged and adding new ones for the Stringer type. Also, ensure the GitHub Actions checks pass.

nodivbyzero avatar Dec 13 '24 20:12 nodivbyzero

Coverage Status

coverage: 73.663% (-0.01%) from 73.677% when pulling e7c250a8cc726fd58285c73a16c9b3102e944e40 on bfabio:urls into bc77d03bfbd951ad1299267754e230b0af36a5aa on go-playground:master.

coveralls avatar Jul 02 '25 07:07 coveralls

I rebased to include #1444 and tweaked it a bit.

@nodivbyzero @go-playground/validator-maintainers

bfabio avatar Jul 02 '25 07:07 bfabio

@nodivbyzero wdyt?

bfabio avatar Aug 14 '25 05:08 bfabio