added additional tests for parent id

This commit is contained in:
$(pass /github/name)
2024-07-12 18:58:32 +02:00
parent 0b2ad57864
commit ac037b12e0
2 changed files with 14 additions and 2 deletions

View File

@@ -68,6 +68,17 @@ func ValidateRequiredMembershipField(fl validator.FieldLevel) bool {
// Get the value of the field specified by RequiredMembershipField
fieldValue := reflect.ValueOf(membership).FieldByName(fieldName)
// Check if the fieldValue is valid
if !fieldValue.IsValid() {
return false
}
// Check if the fieldValue is a nil pointer
if fieldValue.Kind() == reflect.Ptr && fieldValue.IsNil() {
return false
}
// Ensure that the fieldValue is an int64
var fieldInt64 int64
if fieldValue.Kind() == reflect.Int64 {