go-proto-validators icon indicating copy to clipboard operation
go-proto-validators copied to clipboard

Support for multibyte strings

Open tomtwinkle opened this issue 3 years ago • 0 comments

len(string) does not count by characters but by bytes, so if a multibyte string is specified for validation, it cannot be validated by characters. In order to accurately determine the number of characters, len([]rune(string)) should be used.

https://github.com/mwitkow/go-proto-validators/blob/32a686adf8b5194d3ea07d632d49b6fb344af678/plugin/plugin.go#L446

v0.3.2 generated

	if !(len(this.Keyword) < 1000) {

I think this is a good way to fix it.

	if !(len([]rune(this.Keyword)) < 1000) {

tomtwinkle avatar Mar 23 '21 07:03 tomtwinkle