Documentation
¶
Overview ¶
debug.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
element.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
html.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
interactive.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
model.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
prompts.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
python.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sqlite.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
types.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
transcript.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
util.go is part of the Go models package.
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
- Constants
- Variables
- func ElementToHTML(out io.Writer, cssBaseClass string, elem *Element) error
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func IsValidVarname(s string) bool
- func ModelInteractively(model *Model) error
- func ModelToHTML(out io.Writer, model *Model) error
- func ModelToPythonClass(out io.Writer, model *Model) error
- func ModelToSQLiteScheme(out io.Writer, model *Model) error
- func ModelToTypeScriptClass(out io.Writer, model *Model) error
- func ModelToYAML(out io.Writer, model *Model) error
- func SetDebug(debug bool)
- func SetDefaultTypes(model *Model)
- func ValidateARK(elem *Element, formValue string) bool
- func ValidateArXiv(elem *Element, formValue string) bool
- func ValidateButton(elem *Element, formValue string) bool
- func ValidateCheckbox(elem *Element, formValue string) bool
- func ValidateColor(elem *Element, formValue string) bool
- func ValidateDOI(elem *Element, formValue string) bool
- func ValidateDate(elem *Element, formValue string) bool
- func ValidateDateTimeLocal(elem *Element, formValue string) bool
- func ValidateEAN(elem *Element, formValue string) bool
- func ValidateEmail(elem *Element, formValue string) bool
- func ValidateFundRef(elem *Element, formValue string) bool
- func ValidateISBN(elem *Element, formValue string) bool
- func ValidateISNI(elem *Element, formValue string) bool
- func ValidateISSN(elem *Element, formValue string) bool
- func ValidateImage(elem *Element, formValue string) bool
- func ValidateLCNAF(elem *Element, formValue string) bool
- func ValidateList(elem *Element, formValue string) bool
- func ValidateMonth(elem *Element, formValue string) bool
- func ValidateNumber(elem *Element, formValue string) bool
- func ValidateORCID(elem *Element, formValue string) bool
- func ValidateObject(elem *Element, formValue string) bool
- func ValidatePMCID(elem *Element, formValue string) bool
- func ValidatePMID(elem *Element, formValue string) bool
- func ValidatePassword(elem *Element, formValue string) bool
- func ValidateROR(elem *Element, formValue string) bool
- func ValidateRadio(elem *Element, formValue string) bool
- func ValidateRange(elem *Element, formValue string) bool
- func ValidateReset(elem *Element, formValue string) bool
- func ValidateSNAC(elem *Element, formValue string) bool
- func ValidateSearch(elem *Element, formValue string) bool
- func ValidateSubmit(elem *Element, formValue string) bool
- func ValidateTel(elem *Element, formValue string) bool
- func ValidateText(elem *Element, formValue string) bool
- func ValidateTextarea(elem *Element, formValue string) bool
- func ValidateTime(elem *Element, formValue string) bool
- func ValidateURL(elem *Element, formValue string) bool
- func ValidateUUID(elem *Element, formValue string) bool
- func ValidateVIAF(elem *Element, formValue string) bool
- func ValidateWeek(elem *Element, formValue string) bool
- func ValidateWikidata(elem *Element, formValue string) bool
- type Element
- func GenerateARK() *Element
- func GenerateArXiv() *Element
- func GenerateButton() *Element
- func GenerateCheckbox() *Element
- func GenerateColor() *Element
- func GenerateDOI() *Element
- func GenerateDate() *Element
- func GenerateDateTimeLocal() *Element
- func GenerateEAN() *Element
- func GenerateEmail() *Element
- func GenerateFundRef() *Element
- func GenerateISBN() *Element
- func GenerateISNI() *Element
- func GenerateISSN() *Element
- func GenerateImage() *Element
- func GenerateLCNAF() *Element
- func GenerateList() *Element
- func GenerateMonth() *Element
- func GenerateNumber() *Element
- func GenerateORCID() *Element
- func GenerateObject() *Element
- func GeneratePMCID() *Element
- func GeneratePMID() *Element
- func GeneratePassword() *Element
- func GenerateROR() *Element
- func GenerateRadio() *Element
- func GenerateRange() *Element
- func GenerateReset() *Element
- func GenerateSNAC() *Element
- func GenerateSearch() *Element
- func GenerateSubmit() *Element
- func GenerateTel() *Element
- func GenerateText() *Element
- func GenerateTextarea() *Element
- func GenerateTime() *Element
- func GenerateURL() *Element
- func GenerateUUID() *Element
- func GenerateVIAF() *Element
- func GenerateWeek() *Element
- func GenerateWikidata() *Element
- func NewElement(elementId string) (*Element, error)
- type FieldError
- type GenElementFunc
- type Model
- func (model *Model) Changed(state bool)
- func (model *Model) Check(buf io.Writer) bool
- func (model *Model) Define(typeName string, genElementFn GenElementFunc, validateFn ValidateFunc)
- func (model *Model) GenElementType(typeName string) (*Element, bool)
- func (m *Model) GetAttributeIds() []string
- func (m *Model) GetElementById(id string) (*Element, bool)
- func (m *Model) GetElementIds() []string
- func (m *Model) GetGeneratedTypes() map[string]string
- func (m *Model) GetModelIdentifier() (*Element, bool)
- func (model *Model) GetNestedElement(path string) (*Element, bool)
- func (m *Model) GetPrimaryId() string
- func (model *Model) HasChanges() bool
- func (model *Model) HasElement(elementId string) bool
- func (model *Model) HasElementType(elementType string) bool
- func (model *Model) InsertElement(pos int, element *Element) error
- func (model *Model) IsSupportedElementType(eType string) bool
- func (model *Model) ModelToYAML(out io.Writer) error
- func (model *Model) Register(name string, fn RenderFunc)
- func (model *Model) RemoveElement(elementId string) error
- func (model *Model) Render(out io.Writer, name string) error
- func (m *Model) SupportedElementTypes() []string
- func (model *Model) ToHTML(out io.Writer) error
- func (model *Model) ToSQLiteScheme(out io.Writer) error
- func (model *Model) UpdateElement(elementId string, element *Element) error
- func (model *Model) Validate(formData map[string]string) bool
- func (model *Model) ValidateInterface(data interface{}) bool
- func (model *Model) ValidateInterfaceErrors(data interface{}) []FieldError
- func (model *Model) ValidateMapInterface(data map[string]interface{}) bool
- func (model *Model) ValidateRecursive(data interface{}, elem *Element, path string) bool
- type Prompt
- func (prompt *Prompt) GetAnswer(defaultAnswer string, lower bool) string
- func (prompt *Prompt) GetAnswers(defaultAnswer string, defaultValue string, lower bool) (string, string)
- func (prompt *Prompt) GetDigit(choices []string) (int, bool)
- func (prompt *Prompt) Menu(header string, footer string, choices []string)
- func (prompt *Prompt) NumberedMenu(header string, footer string, choices []string)
- func (prompt *Prompt) SelectMenu(header string, footer string, choices []string, defaultAnswer string, ...) (string, string)
- func (prompt *Prompt) SelectNumberedMenu(header string, footer string, choices []string) (int, bool)
- type RenderFunc
- type ValidateFunc
Constants ¶
const ( OrcidPattern = `[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9A-Z]` RORPattern = `^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$` ISNIPattern = `[0-9]{4} [0-9]{4} [0-9]{4} [0-9X]{4}|[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9X]{4}` // ISBN patterns - use simple placeholder patterns; real validation done in ValidateISBN ISBN10Pattern = `[0-9\- ]{10,17}` ISBN13Pattern = `[0-9\- ]{13,26}` ISBNPattern = `[0-9\- ]{10,26}` // ISSN pattern ISSNPattern = `[0-9\- ]{8,10}` // DOI pattern - placeholder, real validation in ValidateDOI function DOIPattern = `10\.[0-9/\-_.:]+` // ArXiv patterns ARXIVPattern = `arxiv:[0-9a-z\./\-]+` // EAN pattern (same as ISBN-13) EANPattern = ISBN13Pattern // PMID pattern PMIDPattern = `^[0-9]+$` // PMCID pattern PMCIDPattern = `^PMC[0-9]+$` // FundRef pattern FundRefPattern = `^10\.[0-9]{4,9}/[-._;()/:A-Z0-9]+$` // LCNAF pattern LCNAFPattern = `^[a-zA-Z0-9]+$` // VIAF pattern VIAFPattern = `^[0-9]+$` // SNAC pattern SNACPattern = `^[0-9]+$` // ARK pattern: optional ark:/ prefix, 5-digit NAAN, slash, name ARKPattern = `^ark:/?[0-9]{5}/[-.a-zA-Z0-9_~]+` // Wikidata QID pattern: Q followed by one or more digits WikidataPattern = `^Q[0-9]+$` )
const ( // Version number of release Version = "0.0.7" // ReleaseDate, the date version.go was generated ReleaseDate = "2026-05-11" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "6193413" LicenseText = `` /* 1524-byte string literal not displayed */ )
Variables ¶
var ( ReORCID *regexp.Regexp ReROR *regexp.Regexp ReISNI *regexp.Regexp ReISBN *regexp.Regexp ReISSN *regexp.Regexp ReDOI *regexp.Regexp ReARXIV *regexp.Regexp ReEAN *regexp.Regexp RePMID *regexp.Regexp RePMCID *regexp.Regexp ReFundRef *regexp.Regexp ReLCNAF *regexp.Regexp ReVIAF *regexp.Regexp ReSNAC *regexp.Regexp ReARK *regexp.Regexp ReWikidata *regexp.Regexp )
var ( // Debug turns on verbose log output for model debugging Debug bool )
Functions ¶
func ElementToHTML ¶
ElementToHTML renders an individual element as HTML, includes label as well as input element.
func FmtHelp ¶
func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string
FmtHelp lets you process a text block with simple curly brace markup.
func IsValidVarname ¶ added in v0.0.2
IsValidVarname tests a sting confirms it conforms to Model's naming rule.
func ModelInteractively ¶ added in v0.0.2
func ModelToHTML ¶
ModelToHTML takes a model and renders an input form. The form is not populated with values through that could be done easily via JavaScript and DOM calls.
func ModelToPythonClass ¶ added in v0.0.5
ModelToPythonClass renders a model as a Python class @param out: io.Writer, where you rending the model text into @param model: *Model, the model to be rendered
func ModelToSQLiteScheme ¶
ModelToSQLiteScheme takess a model and renders the SQLite DB Schema to out. @param out: io.Writer, the target to render the text into @param model: *Model, the model to be rendered.
func ModelToTypeScriptClass ¶ added in v0.0.5
ModelToTypeScriptClass render a model as TypeScript interface and class @param out : io.Writer, where the generated code is written @param model : *Model, the model to render as TypeScript. @return error or nil (on success)
func ModelToYAML ¶ added in v0.0.2
ModelToYAML renders a Model struct as YAML
func SetDebug ¶ added in v0.0.4
func SetDebug(debug bool)
SetDebug sets the model's Debug flag to debug
func SetDefaultTypes ¶ added in v0.0.2
func SetDefaultTypes(model *Model)
func ValidateARK ¶ added in v0.0.7
ValidateARK validates an ARK (Archival Resource Key) identifier. Accepts bare NAANs (ark:/NAAN/name) or fully qualified ARKs with qualifiers. The NAAN (Name Assigning Authority Number) must be exactly 5 digits.
func ValidateArXiv ¶ added in v0.0.7
ValidateArXiv validates ArXiv identifier format
func ValidateButton ¶ added in v0.0.2
func ValidateCheckbox ¶ added in v0.0.2
ValidateCheckbox checks is the form value was provided, returns false if empty string recieved for value.
func ValidateColor ¶ added in v0.0.2
ValidateColor checks to see if the value is expressed using Hexidecimal notation
func ValidateDOI ¶ added in v0.0.7
ValidateDOI validates DOI format
func ValidateDate ¶ added in v0.0.2
ValidateDate makes sure the date string conforms to YYYY-MM-DD
func ValidateDateTimeLocal ¶ added in v0.0.2
ValidateDateTimeLocal makes sure the datetime string conforms to Spec: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string
func ValidateEAN ¶ added in v0.0.7
ValidateEAN validates EAN-13 (same as ISBN-13 validation)
func ValidateEmail ¶ added in v0.0.2
ValidateEmail parses email address to confirm it is valid
func ValidateFundRef ¶ added in v0.0.7
ValidateFundRef validates FundRef DOI format
func ValidateISBN ¶ added in v0.0.7
ValidateISBN validates ISBN-10 or ISBN-13 checksum
func ValidateISNI ¶ added in v0.0.2
func ValidateISSN ¶ added in v0.0.7
ValidateISSN validates ISSN checksum
func ValidateImage ¶ added in v0.0.2
ValidateImage, if value is empty string this returns true. NOTE: this func maybe depreciated as this is not a common form element
func ValidateLCNAF ¶ added in v0.0.7
ValidateLCNAF validates LCNAF format
func ValidateList ¶ added in v0.0.7
ValidateList is a no-op at the scalar level; list contents are validated recursively by the model's validateListErrors method.
func ValidateMonth ¶ added in v0.0.2
ValidateMonth parses the string for a year and month value, i.e. YYYY-MM style date string
func ValidateNumber ¶ added in v0.0.2
ValidateNumber implements a number validation using the json package.
func ValidateORCID ¶ added in v0.0.2
func ValidateObject ¶ added in v0.0.7
ValidateObject is a no-op at the scalar level; object contents are validated recursively by the model's validateObjectErrors method.
func ValidatePMCID ¶ added in v0.0.7
ValidatePMCID validates PubMed Central ID format
func ValidatePMID ¶ added in v0.0.7
ValidatePMID validates PubMed ID format
func ValidatePassword ¶ added in v0.0.2
ValidatePassword makes sure an password input element holds a single string
func ValidateROR ¶ added in v0.0.4
Validate ROR form element
func ValidateRadio ¶ added in v0.0.2
func ValidateRange ¶ added in v0.0.2
ValidateRange retrieves the form's value as a float64 then checks if it is in range. Min and max must befined in the attributes of the element since they are required to make the comparison. NOTE: ValidateRange isn't currently checking the step value as I don't know if the value of the input element is supposed to be an integer for real number.
func ValidateReset ¶ added in v0.0.2
func ValidateSNAC ¶ added in v0.0.7
ValidateSNAC validates SNAC format
func ValidateSearch ¶ added in v0.0.2
func ValidateSubmit ¶ added in v0.0.2
func ValidateTel ¶ added in v0.0.2
ValidateTel validates formValue conforms to a phone number.
func ValidateText ¶ added in v0.0.2
ValidateText will check to see if pattern is set, if so it will evaluate the formValue against the RegExp given in Pattern.
func ValidateTextarea ¶ added in v0.0.2
func ValidateTime ¶ added in v0.0.2
ValidateTime validates the formValue is a time format
func ValidateURL ¶ added in v0.0.2
ValidateURL validates a formValue is a URL
func ValidateUUID ¶ added in v0.0.4
func ValidateVIAF ¶ added in v0.0.7
ValidateVIAF validates VIAF format
func ValidateWeek ¶ added in v0.0.2
ValidateWeek attempts to validate a week number with year, string is WW-YYYY formatted NOTE: this is a crude validation since some years have 52 weeks other 53 depending on how the days of the week line up against the year.
Also noted is this input element isn't widely support by browser so I might drop in the future.
func ValidateWikidata ¶ added in v0.0.7
ValidateWikidata validates a Wikidata QID (e.g. Q42, Q1234567). Strips the https://www.wikidata.org/entity/ prefix if present.
Types ¶
type Element ¶
type Element struct {
// Type, The type of element that you want to input. It is required. Valid values are
// checkboxes, dropdown, input, markdown and text area.
//
// The input type corresponds to the native input types defined for HTML 5. E.g. text, textarea,
// email, phone, date, url, checkbox, radio, button, submit, cancel, select
// See MDN developer docs for input, <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input>
Type string `json:"type,required" yaml:"type,omitempty"`
// Id for the element, except when type is set to markdown. Can only use alpha-numeric characters,
// -, and _. Must be unique in the form definition. If provided, the id is the canonical identifier
// for the field in URL query parameter prefills.
Id string `json:"id,omitempty" yaml:"id,omitempty"`
// Attributes, a set of key-value pairs that define the properties of the element.
// This is a required element as it holds the "value" attribute when expressing
// HTML content. Other commonly use attributes
Attributes map[string]string `json:"attributes,omitempty" yaml:"attributes,omitempty"`
// Pattern holds a validation pattern. When combined with an input type (or input type alias, e.g. orcid)
// produces a form element that sports a specific client side validation exceptation. This intern can be used
// to generate appropriate validation code server side.
Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
// Options holds a list of values and their labels used for HTML select elements in rendering their option child elements
Options []map[string]string `json:"optoins,omitempty" yaml:"options,omitempty"`
// IsObjectId (i.e. is the identifier of the object) used by for the modeled data.
// It is used in calculating routes and templates where the object identifier is required.
IsObjectId bool `json:"is_primary_id,omitempty" yaml:"is_primary_id,omitempty"`
// Generator indicates the type of automatic population of a field. It is used to
// indicate autoincrement and uuids for primary keys and timestamps for datetime oriented fields.
Generator string `json:"generator,omitempty" yaml:"generator,omitempty"`
// Label is used when rendering an HTML form as a label element tied to the input element via the set attribute and
// the element's id.
Label string `json:"label,omitempty" yaml:"label,omitempty"`
// Elements holds nested elements for object and list types. For objects, this defines
// the sub-fields. For lists, this defines the element type that can be repeated.
// This enables modeling complex structures like CrossRef authors (list of objects
// with nested fields like given, family, orcid, affiliation).
Elements []*Element `json:"elements,omitempty" yaml:"elements,omitempty"`
// IsList indicates this element represents an array/list of values.
// When true, the element expects multiple instances of its type (or nested Elements).
IsList bool `json:"is_list,omitempty" yaml:"is_list,omitempty"`
// IsObject indicates this element represents a nested object/map.
// When true, the element contains sub-elements defined in Elements.
IsObject bool `json:"is_object,omitempty" yaml:"is_object,omitempty"`
// contains filtered or unexported fields
}
Element implementes the GitHub YAML issue template syntax for an input element. The input element YAML is described at <https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema>
While the syntax most closely express how to setup an HTML representation it is equally suitable to expressing, through inference, SQL column type definitions. E.g. a bare `input` type is a `varchar`, a `textarea` is a `text` column type, an `input[type=date]` is a date column type.
func GenerateARK ¶ added in v0.0.7
func GenerateARK() *Element
GenerateARK sets up for an HTML input type text using a pattern for ARK identifiers
func GenerateArXiv ¶ added in v0.0.7
func GenerateArXiv() *Element
GenerateArXiv sets up for an HTML input type text using a pattern for ArXiv
func GenerateButton ¶ added in v0.0.2
func GenerateButton() *Element
GenerateButton sets up for an HTML input type "button"
func GenerateCheckbox ¶ added in v0.0.2
func GenerateCheckbox() *Element
GenerateCheckbox sets up for an HTML input type "checkbox"
func GenerateColor ¶ added in v0.0.2
func GenerateColor() *Element
GenerateColor sets up for HTML input type "color"
func GenerateDOI ¶ added in v0.0.7
func GenerateDOI() *Element
GenerateDOI sets up for an HTML input type text using a pattern for DOI
func GenerateDate ¶ added in v0.0.2
func GenerateDate() *Element
GenerateDate setups up for HTML date input element
func GenerateDateTimeLocal ¶ added in v0.0.2
func GenerateDateTimeLocal() *Element
GenerateDateTimeLocal sets up for HTML input type "datetime-local"
func GenerateEAN ¶ added in v0.0.7
func GenerateEAN() *Element
GenerateEAN sets up for an HTML input type text using a pattern for EAN (same as ISBN-13)
func GenerateEmail ¶ added in v0.0.2
func GenerateEmail() *Element
GenerateEmail sets up for HTML input type "email"
func GenerateFundRef ¶ added in v0.0.7
func GenerateFundRef() *Element
GenerateFundRef sets up for an HTML input type text using a pattern for FundRef DOI
func GenerateISBN ¶ added in v0.0.7
func GenerateISBN() *Element
GenerateISBN sets up for an HTML input type text using a pattern for ISBN (10 or 13)
func GenerateISNI ¶ added in v0.0.2
func GenerateISNI() *Element
GenerateISNI sets up for an HTML input type "text" with a pattern for INSI input
func GenerateISSN ¶ added in v0.0.7
func GenerateISSN() *Element
GenerateISSN sets up for an HTML input type text using a pattern for ISSN
func GenerateImage ¶ added in v0.0.2
func GenerateImage() *Element
GenerateImage sets up for an HTML input type "image"
func GenerateLCNAF ¶ added in v0.0.7
func GenerateLCNAF() *Element
GenerateLCNAF sets up for an HTML input type text using a pattern for LCNAF
func GenerateList ¶ added in v0.0.7
func GenerateList() *Element
GenerateList sets up a list element (a repeatable sequence of sub-elements). At the web form level this is typically rendered as a JSON-encoded textarea.
func GenerateMonth ¶ added in v0.0.2
func GenerateMonth() *Element
GenerateMonth sets up for HTML input type "month"
func GenerateNumber ¶ added in v0.0.2
func GenerateNumber() *Element
GenerateNumber sets up for an HTML input type "number"
func GenerateORCID ¶ added in v0.0.2
func GenerateORCID() *Element
GenerateORCID sets up for an HTML input type text using a pattern for ORCID
func GenerateObject ¶ added in v0.0.7
func GenerateObject() *Element
GenerateObject sets up an object element (a named set of sub-elements). At the web form level this is typically rendered as a JSON-encoded textarea.
func GeneratePMCID ¶ added in v0.0.7
func GeneratePMCID() *Element
GeneratePMCID sets up for an HTML input type text using a pattern for PubMed Central ID
func GeneratePMID ¶ added in v0.0.7
func GeneratePMID() *Element
GeneratePMID sets up for an HTML input type text using a pattern for PubMed ID
func GeneratePassword ¶ added in v0.0.2
func GeneratePassword() *Element
GeneratePassword sets up for an HTML input type "password"
func GenerateROR ¶ added in v0.0.4
func GenerateROR() *Element
GenerateROR setups up for an HTML ROR type input element
func GenerateRadio ¶ added in v0.0.2
func GenerateRadio() *Element
GenerateRadio sets up for an HTML input type "radio"
func GenerateRange ¶ added in v0.0.2
func GenerateRange() *Element
GenerateRange sets up for an HTML input "range" (defauting is min 0 to max 100, step 1)
func GenerateReset ¶ added in v0.0.2
func GenerateReset() *Element
GenerateReset sets up for an HTML input type "reset"
func GenerateSNAC ¶ added in v0.0.7
func GenerateSNAC() *Element
GenerateSNAC sets up for an HTML input type text using a pattern for SNAC
func GenerateSearch ¶ added in v0.0.2
func GenerateSearch() *Element
GenerateSearch sets up HTML input type "search"
func GenerateSubmit ¶ added in v0.0.2
func GenerateSubmit() *Element
GenerateSubmit sets up for an HTML input type "submit"
func GenerateTel ¶ added in v0.0.2
func GenerateTel() *Element
GenerateTel sets up for an HTML input type "tel" (i.e. telephone number).
func GenerateText ¶ added in v0.0.2
func GenerateText() *Element
GenerateText generates an Element setup to hold an HTML text input elements
func GenerateTextarea ¶ added in v0.0.2
func GenerateTextarea() *Element
GenerateTextarea sets up for HTML textarea input
func GenerateTime ¶ added in v0.0.2
func GenerateTime() *Element
GenerateTime sets up for an HTML input type "time"
func GenerateURL ¶ added in v0.0.2
func GenerateURL() *Element
GenerateURL sets up for an HTML input type "url"
func GenerateUUID ¶ added in v0.0.4
func GenerateUUID() *Element
GenerateUUID setups up for an HTML uuid type input element
func GenerateVIAF ¶ added in v0.0.7
func GenerateVIAF() *Element
GenerateVIAF sets up for an HTML input type text using a pattern for VIAF
func GenerateWeek ¶ added in v0.0.2
func GenerateWeek() *Element
GenerateWeek generates an Element setup to hold an HTML week input
func GenerateWikidata ¶ added in v0.0.7
func GenerateWikidata() *Element
GenerateWikidata sets up for an HTML input type text for Wikidata QIDs
func NewElement ¶
NewElement, makes sure element id is valid, populates an element as a basic input type. The new element has the attribute "name" and label set to default values.
func (*Element) HasChanged ¶ added in v0.0.2
HasChanged checks to see if the Element has been changed.
func (*Element) IsListType ¶ added in v0.0.7
IsListType returns true when this element represents a list, whether expressed as type: list (canonical) or the legacy is_list: true boolean.
func (*Element) IsObjectType ¶ added in v0.0.7
IsObjectType returns true when this element represents an object, whether expressed as type: object (canonical) or the legacy is_object: true boolean.
type FieldError ¶ added in v0.0.7
type FieldError struct {
// Path is the dot-notation path to the failing field, e.g. "author[0].family"
Path string
// Message describes why validation failed
Message string
// Type is the element type that was expected, if known
Type string
}
FieldError describes a validation failure at a specific field path.
func (FieldError) Error ¶ added in v0.0.7
func (fe FieldError) Error() string
type GenElementFunc ¶ added in v0.0.2
type GenElementFunc func() *Element
GenElementFunc is a function which will generate an Element configured represent a model's supported "types"
type Model ¶
type Model struct {
// Id is a required field for model, it maps to the HTML element id and name
Id string `json:"id,required" yaml:"id"`
// This is a Newt specifc set of attributes to place in the form element of HTML. I.e. it could
// be form "class", "method", "action", "encoding". It is not defined in the GitHub YAML issue template syntax
// (optional)
Attributes map[string]string `json:"attributes,omitempty" yaml:"attributes,omitempty"`
// Description, A description for the issue form template, which appears in the template chooser interface.
// (required)
Description string `json:"description,required" yaml:"description,omitempty"`
// Elements, Definition of the input types in the form.
// (required)
Elements []*Element `json:"elements,required" yaml:"elements,omitempty"`
// contains filtered or unexported fields
}
Model implements a data structure description inspired by GitHub YAML issue template syntax. See <https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms>
The Model structure describes the HTML elements used to form a record. It can be used in code generation and in validating POST and PUT requests in datasetd.
func NewModel ¶
NewModel, makes sure model id is valid, populates a Model with the identifier element providing returns a *Model and error value.
func (*Model) Check ¶
Check analyze the model and make sure at least one element exists and the model has a single identifier (e.g. "identifier")
func (*Model) Define ¶ added in v0.0.2
func (model *Model) Define(typeName string, genElementFn GenElementFunc, validateFn ValidateFunc)
Define takes a model and attaches a type definition (an element generator) and validator for the named type
func (*Model) GenElementType ¶ added in v0.0.2
GenElementType takes an element type and returns an Element struct populated for that type and true or nil and false if type is not supported.
func (*Model) GetAttributeIds ¶
GetAttributeIds returns a slice of attribute ids found in the model's .Elements
func (*Model) GetElementById ¶
GetElementById returns a Element from the model's .Elements.
func (*Model) GetElementIds ¶
GetElementIds returns a slice of element ids found in the model's .Elements
func (*Model) GetGeneratedTypes ¶ added in v0.0.4
GetGeneratedTypes returns a map of elemend id and value held by .Generator
func (*Model) GetModelIdentifier ¶
GetModelIdentifier() returns the element which describes the model identifier. Returns the element and a boolean set to true if found.
func (*Model) GetNestedElement ¶ added in v0.0.7
GetNestedElement returns a nested element by its path (e.g., "author.0.given"). Path segments are separated by dots. Array indices are supported with bracket notation.
func (*Model) GetPrimaryId ¶ added in v0.0.4
GetPrimaryId returns the primary id
func (*Model) HasChanges ¶
HasChanges checks if the model's elements have changed
func (*Model) HasElement ¶
HasElement checks if the model has a given element id
func (*Model) HasElementType ¶
HasElementType checks if an element type matches given type.
func (*Model) InsertElement ¶
InsertElement will add a new element to model.Elements in the position indicated, It will also set isChanged to true on additional.
func (*Model) IsSupportedElementType ¶ added in v0.0.2
IsSupportedElementType checks if the element type is supported by Newt, returns true if OK false is it is not
func (*Model) ModelToYAML ¶ added in v0.0.2
ModelInteractively takes a model and interactively prompts to create a YAML model file.
func (*Model) Register ¶
func (model *Model) Register(name string, fn RenderFunc)
Register takes a name (string) and a RenderFunc and registers it with the model. Registered names then can be invoke by the register name.
func (*Model) RemoveElement ¶
RemoveElement removes an element by id from the model.Elements
func (*Model) Render ¶
Render takes a register render io.Writer and register name envoking the function with the model.
func (*Model) SupportedElementTypes ¶ added in v0.0.7
SupportedElementTypes returns a sorted list of all registered type names.
func (*Model) ToSQLiteScheme ¶
ToSQLiteScheme takes a model and trys to render a SQLite3 SQL create statement.
func (*Model) UpdateElement ¶
UpdateElement will update an existing element with element id will the new element.
func (*Model) ValidateInterface ¶ added in v0.0.7
ValidateInterface validates the entire data structure against the model's schema. Returns true if valid. For detailed errors use ValidateInterfaceErrors.
func (*Model) ValidateInterfaceErrors ¶ added in v0.0.7
func (model *Model) ValidateInterfaceErrors(data interface{}) []FieldError
ValidateInterfaceErrors validates data against the model's schema and returns all field-level errors. An empty slice means validation passed. Handles both flat and nested structures (lists and objects).
func (*Model) ValidateMapInterface ¶ added in v0.0.4
ValidateMapInterface normalizes the map inteface values before calling the element's validator function. This is the legacy validation method for flat (non-nested) models. For nested structures, use ValidateRecursive or Validate instead.
func (*Model) ValidateRecursive ¶ added in v0.0.7
ValidateRecursive validates data against an element schema, supporting nested structures. Returns true if valid. For detailed errors use validateRecursiveErrors.
type Prompt ¶ added in v0.0.3
type Prompt struct {
// contains filtered or unexported fields
}
Prompt holds the elements need to present questions and menus to build simple conversational console interfaces
func NewPrompt ¶ added in v0.0.3
NewPrompt creates a new prompt struct for use with the prompt methods. @param in: io.Reader, the source of prompt responses. @param out: io.Writer, the place the response is written to (e.g. Stdout) @param eout: io.Writer, the place errors are written to (e.g. Stderr)
```
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
```
func (*Prompt) GetAnswer ¶ added in v0.0.3
GetAnswer display a string and get a response, e.g. "Are you Happy (Y/n)?"
```
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
fmt.Println("Are you happy (Y/n)?")
answser := prompt.GetAnswer("y", true)
if answer == "y" {
fmt.Println("Yeah! We're happy.")
} else {
fmt.Println("I'm sad too.")
}
```
func (*Prompt) GetAnswers ¶ added in v0.0.3
func (prompt *Prompt) GetAnswers(defaultAnswer string, defaultValue string, lower bool) (string, string)
GetAnswers returns an answer which has an initial verb and an predicate separted by a space. E.g. "sleeping now" -> "sleeping" "now" or "sleeping at 10:00am" -> "sleeping" "at 10:00am"
```
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
fmt.Println("Enter an action and object")
verb, object := prompt.GetAnswers("sleeping", "now", false)
fmt.Printf("Are you %q? %q?", verb, object)
```
func (*Prompt) GetDigit ¶ added in v0.0.3
GetDigit returns a numeric answer that is greater than or equal than zero and less than the number of choices.
The response integer is normalized to a zero based array. E.g. a user inputs the number three it is normalized to two so it aligns with the choices present.
```
choices := []string{
"Vanilla",
"Strawberry",
"Coffee",
"",
"Decline ice cream",
}
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
prompt.NumberedMenu("Enter number for choice", "Pick your flavor:", choices)
if x, ok := prompt.GetDigit(choices); ok {
fmt.Printf("You selected %d\n", x)
} else {
fmt.Printf("No selection\n")
}
```
func (*Prompt) Menu ¶ added in v0.0.3
Menu displays header, a list of choices and footer to form a menu.
```
choices := []string{
"[1] Vanilla",
"[2] Strawberry",
"[3] Coffee",
"",
"[q]uit to decline ice cream",
}
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
prompt.Menu(MenuHeader, MenuFooter, choices)
```
func (*Prompt) NumberedMenu ¶ added in v0.0.3
NumberedMenu displays header, a list of choices and footer. The choices are numbered when forming the menu. Only non-empty strings are numbered.
```
choices := []string{
"Vanilla",
"Strawberry",
"Coffee",
"",
"Decline ice cream",
}
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
prompt.Menu("Enter a number and press enter", "Pick your flavor:", choices)
```
func (*Prompt) SelectMenu ¶ added in v0.0.3
func (prompt *Prompt) SelectMenu(header string, footer string, choices []string, defaultAnswer string, defaultValue string, lower bool) (string, string)
SelectMenu display a menu and return answer(s).
```
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
choices := []string{
"[v]anilla",
"[c]hocolate",
"[s]trawberry",
}
flavor, scoops := prompt.SelectMenuItem(
"Menu: enter flavor letter and number of scoops",
"E.g. three vanilla scoops, "c 3",
choices, "", "", true)
fmt.Printf("You selected %q of flavor %q.\n", scoops, flavor)
```
func (*Prompt) SelectNumberedMenu ¶ added in v0.0.3
func (prompt *Prompt) SelectNumberedMenu(header string, footer string, choices []string) (int, bool)
SelectNumberedMenu display a numbered menu and return the intereger and OK status.
```
prompt := NewPrompt(os.Stdin, os.Stdout, os.Stderr)
choices := []string{
"vanilla",
"chocolate",
"strawberry",
"",
"decline ice cream",
}
i, ok := prompt.SelectMenuNumber(
"Menu: enter flavor number",
"E.g. 1 for vanilla",
choices, "", "", true)
fmt.Printf("You selected %d, status %t\n", i, ok)
```
type RenderFunc ¶
RenderFunc is a function thation takes an io.Writer and Model then renders the model into the io.Writer. It is used to extend the Model to support various output formats.
type ValidateFunc ¶ added in v0.0.2
ValidateFunc is a function that validates form assocaited with the Element and the string value received in the web form (value before converting to Go type).