Skip to content

Generate input validation for form fields using input attributes from HTML #10

Description

@crhntr

Given a form

{{define `ParseInputs[UpdateProfile]`}}
<form id="update-profile">
  <input type="text" name="first-name" required>
  <input type="date" name="favorite-holiday" data-time-format="2006-01-02">
</form>
{{end}}

Muxt should generate and add it to template_routes.go

type UpdateProfile struct{
  FirstName       string    `name:"first-name"`
  FavoriteHoliday time.time `name:"favorite-holiday"`
}

Support input types

input type Go type first draft Go type someday
checkbox bool
color string color.Color
date string time.Time
datetime-local string time.Time: use data-time-format to parse the string
email string string
file multipart.File
hidden string use data-type
image
month string time.Time: use data-time-format to parse the string
number string use data-type; if step is an int, use int otherwise use float64
password string use data-type
radio string use data-type
range string use data-types; if step is an int, use int otherwise use float64
search string use data-type
tel string use data-type
text string use data-type
time string time.Time: use data-time-format to parse the string
url url.URL
week string use data-time-format and parse time.Time

Initially add validation logic for:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions