go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.89k stars 1.32k forks source link

`datauri` fails to accept valid data URIs. #518

Open puellanivis opened 5 years ago

puellanivis commented 5 years ago

Package version eg. v8, v9:

master

Code sample, to showcase or reproduce:

fmt.Println(dataURIRegex.MatchString(`data:,ohai`)

Prints false it should print true.

This is an inherited problem from every other validation library out there. This same regex keeps getting copied around.

Wikipedia gives a pretty clear guidance about what a valid Data URI is: data:[<media type>][;base64],<data> note the optional state of <media type> and even of the ;base64 element, and the requirement of a comma.

deankarn commented 5 years ago

@puellanivis thanks for reporting, can you make a PR to correct?