go-playground / validator

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

alphanum raising error for space characters #1117

Open abhinavk1807 opened 1 year ago

abhinavk1807 commented 1 year ago

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")
    }
}
sandeep-adireddi commented 1 year ago

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).