package
0.2.10
Repository: https://github.com/daarlabs/hirokit.git
Documentation: pkg.go.dev

# README

Creamsensation - Form

Example code

package example

import . "github.com/creamsensation/form"

type ExampleForm struct {
  Form
  Name  Field[string] 
  Age   Field[int]
}

func createExampleForm() (ExampleForm, error) {
  form := New(
    Add("name").With(Text(), Validate.Required()),
    Add("age").With(Number[int](), Validate.Required()),
  )
  return Build[ExampleForm](form)
}

New()

Creates new form builder, which accept field builders

New(fields...)

Builder - Action()

Set form action

formBuilder.Action(action)

Builder - Add()

Same as Add() function, only alternative

formBuilder.Add(name)

Builder - Get()

Get form field

formBuilder.Get(name)

Builder - Limit()

Data limit (MBs)

formBuilder.Limit(limit)

Builder - Method()

Set form method

formBuilder.Method(method)

Builder - Name()

Set form name

formBuilder.Name(name)

Builder - Request()

Provide request to form, it uses native *http.Request

formBuilder.Request(request)

Add()

Creates new field builder

Add(config, validators...)

Validate

Validate - Required()

Use when form field value is required, it works with string, int, floats, bool and Multipart

Validate.Required()
--
Add("example").With(Text(), Validate.Required())

Validate - Min()

Use when form field value must have minimal value or minimal length, it works with string, int, floats

Validate.Min(1)
--
Add("text").With(Text(), Validate.Min(1))
Add("amount").With(Number[float64](), Validate.Min(1))

Validate - Max()

Use when form field value must have maximum value or maximum length, it works with string, int, floats

Validate.Max(10)
--
Add("text").With(Text(), Validate.Max(10))
Add("amount").With(Number[float64](), Validate.Max(10))

Validate - Email()

Use when form field value must have email pattern, it works with string

Validate.Email()
--
Add("email").With(Email("[email protected]"), Validate.Email())

Build()

Creates form from form builder, you have to provide result type

Build[ExampleForm](formBuilder)

CreateStruct()

Convert form struct to any data model struct, you have to provide source and result type

CreateStruct[ExampleForm, Model](&form)

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author