Ver Fonte

FieldNames fix

0x4a52466c696e74 há 1 ano atrás
pai
commit
3bc5d4da87
1 ficheiros alterados com 12 adições e 1 exclusões
  1. 12 1
      fielder.go

+ 12 - 1
fielder.go

@@ -242,8 +242,19 @@ func Fields(obj any, files RequestFiles, names ...any) (json.Map, IErrorArgs) {
 	return res, nil
 }
 
+type FieldNamesList []string
+
+func (s FieldNamesList) Exists(name string) bool {
+	for _, fName := range s {
+		if fName == name {
+			return true
+		}
+	}
+	return false
+}
+
 // GetStructFields возвращает список полей структуры
-func FieldNames(s any) ([]string, error) {
+func FieldNames(s any) (FieldNamesList, error) {
 	// Получаем тип и проверяем, что это структура
 	t := reflect.TypeOf(s)
 	if t.Kind() == reflect.Ptr || t.Kind() == reflect.Interface {