Repository: gookit/validate

Issue:
无法验证 url.query 中包含数组的情况
**System (please complete the following information):**

 - OS: `macOS`
 - GO Version: `1.23`
 - Pkg Version: `1.5.4`

**Describe the bug**

请求连接：`/a?date=2023-03&date=2023-04` 中包含数组时，无法进行正常校验。

**To Reproduce**

```go
// 模拟 FromURLValues
v := validate.New(map[string][]string{
	"date": {"2023-03", "2023-04"},
})

v.StringRule("date", "required|array|len:2")
v.StringRule("date.*", "required|date")

if v.Validate() {
	fmt.Println(v.SafeData())
} else {
	fmt.Println(v.Errors)
}
```

Print:

```
date:
 len: date field did not pass validation
 array: date value must be an array
date.*:
 required: date.* is required to not be empty
```

**Expected behavior**

可以根据代码中规则正常通过校验。

**Additional context**

问题代码：https://github.com/gookit/validate/blob/master/data_source.go#L845




Discussion:
@hwbrzzl: Hey @inhere 请问版本发布周期是怎样的？最近可否发布一个新版本奥？

Solution patch:
diff --git a/data_source.go b/data_source.go
index 1f4307d..db74ae3 100644
--- a/data_source.go
+++ b/data_source.go
@@ -841,7 +841,11 @@ func (d FormData) TryGet(key string) (val any, exist, zero bool) {
 // Get value by key
 func (d FormData) Get(key string) (any, bool) {
 	// get form value
+	key, _, _ = strings.Cut(key, ".*")
 	if vs, ok := d.Form[key]; ok && len(vs) > 0 {
+		if len(vs) > 1 {
+			return vs, true
+		}
 		return vs[0], true
 	}
 
diff --git a/validators.go b/validators.go
index d83d143..2818799 100644
--- a/validators.go
+++ b/validators.go
@@ -1198,8 +1198,8 @@ func StringLength(val any, minLen int, maxLen ...int) bool {
  *************************************************************/
 
 // IsDate check value is an date string.
-func IsDate(srcDate string) bool {
-	_, err := strutil.ToTime(srcDate)
+func IsDate(srcDate string, layouts ...string) bool {
+	_, err := strutil.ToTime(srcDate, layouts...)
 	return err == nil
 }
 



Test patch:
diff --git a/data_source_test.go b/data_source_test.go
index 4d29d43..420779b 100644
--- a/data_source_test.go
+++ b/data_source_test.go
@@ -57,6 +57,7 @@ func TestFormData(t *testing.T) {
 		"age":    {"30"},
 		"notify": {"true"},
 		"money":  {"23.4"},
+		"emails": {"some@email.com", "other@email.com"},
 	})
 
 	is.True(d.Has("notify"))
@@ -74,7 +75,8 @@ func TestFormData(t *testing.T) {
 	is.Equal(23.4, d.Float("money"))
 	is.Equal(float64(0), d.Float("not-exist"))
 	is.Equal("inhere", d.String("name"))
-	is.Equal("age=30&money=23.4&name=inhere&notify=true", d.Encode())
+	is.Equal([]string{"some@email.com", "other@email.com"}, d.Strings("emails"))
+	is.Equal("age=30&emails=some%40email.com&emails=other%40email.com&money=23.4&name=inhere&notify=true", d.Encode())
 
 	val, exist, zero := d.TryGet("name")
 	is.True(exist)
@@ -85,6 +87,11 @@ func TestFormData(t *testing.T) {
 	is.True(exist)
 	is.Equal("inhere", val)
 
+	emails, exist := d.Get("emails")
+	is.True(exist)
+	is.Len(emails, 2)
+	is.Equal([]string{"some@email.com", "other@email.com"}, emails)
+
 	nval, err := d.Set("newKey", "strVal")
 	is.NoErr(err)
 	is.Equal("strVal", nval)
diff --git a/validators_test.go b/validators_test.go
index d8c4ad6..9af626e 100644
--- a/validators_test.go
+++ b/validators_test.go
@@ -725,6 +725,7 @@ func TestDateCheck(t *testing.T) {
 	is := assert.New(t)
 	// Date
 	is.True(IsDate("2018-10-25"))
+	is.True(IsDate("2018-10", "2006-01"))
 
 	// DateFormat
 	is.True(DateFormat("2018-10-25", "2006-01-02"))