Only check for postal code if we have a valid country

Otherwise, there we can not know the pattern to check against.
This commit is contained in:
jordi fita mas 2023-12-13 23:41:47 +01:00
parent 6e1d5b14bc
commit ded10ded08
1 changed files with 1 additions and 1 deletions

View File

@ -256,7 +256,7 @@ func (f *bookingForm) Valid(ctx context.Context, conn *database.Conn, l *locale.
v.CheckMinLength(f.FullName, 1, l.GettextNoop("Full name must have at least one letter."))
}
if f.PostalCode.Val != "" {
if country != "" && f.PostalCode.Val != "" {
if _, err := v.CheckValidPostalCode(ctx, conn, f.PostalCode, country, l.GettextNoop("This postal code is not valid.")); err != nil {
return false, err
}