0x4a52466c696e74 hai 4 meses
pai
achega
a2fa80a1fb
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      fielder.go

+ 9 - 0
fielder.go

@@ -39,6 +39,10 @@ type IFielderPost interface {
 	RestFieldsPost(result json.Map, files map[string]IReadCloserLen, names FieldList)
 }
 
+type IFieldChecker interface {
+	RestFieldCheck(fieldName string) bool
+}
+
 func fieldsDefault(t reflect.Type) (res []any) {
 	for i := 0; i < t.NumField(); i++ {
 		fType := t.Field(i)
@@ -144,6 +148,11 @@ func fieldVal(val reflect.Value, fieldName string, files RequestFiles, names ...
 				}
 			}
 			if !field.IsValid() {
+				if f, check := val.Interface().(IFieldChecker); check {
+					if check := f.RestFieldCheck(fieldName); check {
+						return true
+					}
+				}
 				err = ErrorFiled(rField.Name, "field is not found")
 				return false
 			}