From f451d69d702b350f7361de930153b88f4638015f Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 1 Oct 2025 23:30:16 +0200 Subject: [PATCH] doc: add documentation of functions and licence --- form/field.go | 2 ++ form/field_collection.go | 10 +++++----- form/form.go | 1 + util/collection.go | 15 +++++++++++++++ util/transformer.go | 15 +++++++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/form/field.go b/form/field.go index f1558c2..fe63326 100644 --- a/form/field.go +++ b/form/field.go @@ -158,6 +158,7 @@ func (f *Field) WithOptions(options ...*Option) *Field { return f } +// Remove an option if exists func (f *Field) RemoveOption(name string) *Field { var options []*Option @@ -377,6 +378,7 @@ func (f *Field) Bind(data map[string]any, key *string, parentIsSlice bool) error return nil } +// Generates a tree of errors func (f *Field) ErrorsTree(tree map[string]any, key *string) { var index string diff --git a/form/field_collection.go b/form/field_collection.go index 52b8e02..3f3ece1 100644 --- a/form/field_collection.go +++ b/form/field_collection.go @@ -1,10 +1,5 @@ package form -import ( - "fmt" - "reflect" -) - // @license GNU AGPL version 3 or any later version // // This program is free software: you can redistribute it and/or modify @@ -20,6 +15,11 @@ import ( // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +import ( + "fmt" + "reflect" +) + // Generates a sub form func NewFieldCollection(name string) *Field { f := NewField(name, "collection"). diff --git a/form/form.go b/form/form.go index c17da05..04016d3 100644 --- a/form/form.go +++ b/form/form.go @@ -293,6 +293,7 @@ func (f *Form) IsSubmitted() bool { return f.RequestData != nil } +// Generates a tree of errors func (f *Form) ErrorsTree() map[string]any { errors := make(map[string]any) diff --git a/util/collection.go b/util/collection.go index 7ee4d66..f0aa649 100644 --- a/util/collection.go +++ b/util/collection.go @@ -1,5 +1,20 @@ package util +// @license GNU AGPL version 3 or any later version +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + import ( "regexp" "strings" diff --git a/util/transformer.go b/util/transformer.go index 743b117..a942fa1 100644 --- a/util/transformer.go +++ b/util/transformer.go @@ -1,5 +1,20 @@ package util +// @license GNU AGPL version 3 or any later version +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + import ( "fmt" "net/url"