replace all schema check with go-playground/validator/v10

This commit is contained in:
yusing
2024-12-18 04:48:29 +08:00
parent 00f60a6e78
commit 6aefe4d5d9
23 changed files with 149 additions and 250 deletions

View File

@@ -1,7 +1,6 @@
package functional
import (
"errors"
"sync"
"github.com/puzpuzpuz/xsync/v3"
@@ -195,31 +194,6 @@ func (m Map[KT, VT]) Has(k KT) bool {
return ok
}
// UnmarshalFromYAML unmarshals a yaml byte slice into the map.
//
// It overwrites all existing key-value pairs in the map.
//
// Parameters:
//
// data: yaml byte slice to unmarshal
//
// Returns:
//
// error: if the unmarshaling fails
func (m Map[KT, VT]) UnmarshalFromYAML(data []byte) error {
if m.Size() != 0 {
return errors.New("cannot unmarshal into non-empty map")
}
tmp := make(map[KT]VT)
if err := yaml.Unmarshal(data, tmp); err != nil {
return err
}
for k, v := range tmp {
m.Store(k, v)
}
return nil
}
func (m Map[KT, VT]) String() string {
tmp := make(map[KT]VT, m.Size())
m.RangeAll(func(k KT, v VT) {