mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-25 18:41:10 +01:00
replace all schema check with go-playground/validator/v10
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user