validator icon indicating copy to clipboard operation
validator copied to clipboard

alphanum raising error for space characters

Open abhinavk1807 opened this issue 1 year ago • 1 comments

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

Package version eg. v9, v10: v10

Issue, Question or Enhancement: ISSUE

blank/space is an accepted alphanumeric character, while tag alphanum is raising error for space characters

Code sample, to showcase or reproduce:

package main

import (
	"fmt"

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

func main() {

	validate := validator.New()
	testString := "ok testing"
	errs := validate.Var(testString, "alphanum")
	if errs != nil {
		fmt.Println("contains err")
	} else {
		fmt.Println("no error")
	}
}

abhinavk1807 avatar Jun 16 '23 10:06 abhinavk1807

In the ASCII character set, the space character is a non-alphanumeric printable character that is used to create space between words or other characters. Alphanumeric characters in ASCII specifically refer to the uppercase letters (A-Z), lowercase letters (a-z), and numeric digits (0-9).

sandeep-adireddi avatar Jun 19 '23 06:06 sandeep-adireddi