Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bootstrap/core/web/components/input/input.templ
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ templ Input(props ...Props) {
if p.Placeholder != "" {
placeholder={ p.Placeholder }
}
if p.Value != "" {
value={ p.Value }
}
if !utils.IsEmptyValue(p.Value) {
value={ p.Value }
}
if p.Type == TypeFile && p.FileAccept != "" {
accept={ p.FileAccept }
}
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/core/web/components/input/input_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions bootstrap/core/web/utils/templui.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ func IsPathStyles(path, expected, trueStyles, falseStyles string) string {
}
return falseStyles
}

func IsEmptyValue(d string) bool {
return d == "" || len(d) != 0
}
2 changes: 1 addition & 1 deletion models/fixtures/model_success.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type PostTest struct {
OptionalString goption.Optional[string] `form:"optional_string" json:"optional_string" mapstructure:"optional_string" param:"optional_string" query:"optional_string"`
String string `form:"string" json:"string" mapstructure:"string" param:"string" query:"string" validate:"required"`
OptionalBool goption.Optional[bool] `form:"optional_bool" json:"optional_bool" mapstructure:"optional_bool" param:"optional_bool" query:"optional_bool"`
Bool bool `form:"bool" json:"bool" mapstructure:"bool" param:"bool" query:"bool" validate:"required"`
Bool bool `form:"bool" json:"bool" mapstructure:"bool" param:"bool" query:"bool"`
OptionalTime goption.Optional[time.Time] `form:"optional_time" json:"optional_time" mapstructure:"optional_time" param:"optional_time" query:"optional_time"`
Time time.Time `form:"time" json:"time" mapstructure:"time" param:"time" query:"time" validate:"required"`
OptionalDecimal goption.Optional[udecimal.Decimal] `form:"optional_decimal" json:"optional_decimal" mapstructure:"optional_decimal" param:"optional_decimal" query:"optional_decimal"`
Expand Down
7 changes: 5 additions & 2 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ func doGenerateModel(input parser.GenerateModelInput, goDeps deps.Container) err
var validationsTags []tags.ValidateGenerable

if !item.IsOptional {
if item.Type == string(types.TypeUuid) {
switch types.SupportedType(item.Type) {
case types.TypeUuid:
validationsTags = append(validationsTags, tags.ValidateRequiredUuid{})
} else {
case types.TypeBool:
// just to avoid the required tag registry
default:
validationsTags = append(validationsTags, tags.ValidateRequired{})
}
}
Expand Down
Loading