Fixed null pointer access on validating booking without dogs or options
This commit is contained in:
parent
0f76351ae9
commit
77a3f78176
|
@ -226,11 +226,11 @@ func (f *bookingForm) Valid(ctx context.Context, conn *database.Conn, l *locale.
|
|||
v.CheckSelectedOptions(f.CampsiteType, l.GettextNoop("Selected campsite type is not valid."))
|
||||
f.Dates.Valid(v, l)
|
||||
f.Guests.Valid(v, l)
|
||||
f.Options.Valid(v, l)
|
||||
if f.Options != nil {
|
||||
if err := f.Customer.Valid(ctx, conn, v, l); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if f.Options != nil {
|
||||
f.Options.Valid(v, l)
|
||||
}
|
||||
return v.AllOK, nil
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ func (f *bookingGuestFields) Valid(v *form.Validator, l *locale.Locale) {
|
|||
v.CheckMinInteger(f.NumberChildren, 0, l.GettextNoop("Number of children can not be negative."))
|
||||
}
|
||||
}
|
||||
if v.CheckRequired(f.NumberDogs, l.GettextNoop("Number of dogs can not be empty")) {
|
||||
if f.NumberDogs != nil && v.CheckRequired(f.NumberDogs, l.GettextNoop("Number of dogs can not be empty")) {
|
||||
if v.CheckValidInteger(f.NumberDogs, l.GettextNoop("Number of dogs must be an integer.")) {
|
||||
v.CheckMinInteger(f.NumberDogs, 0, l.GettextNoop("Number of dogs can not be negative."))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue