validator

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validator

type Validator struct {
	Name string
}

func NewValidator

func NewValidator(name string) *Validator

NewValidator creates and returns a new instance of Validator with the specified name.

Parameters:

  • name: The name of the prompt being validated.

Returns:

  • *Validator: A pointer to the newly created Validator instance.

func (*Validator) Panic

func (v *Validator) Panic(cause string)

Panic triggers a panic with a formatted message that includes the validator's name and the provided cause.

Parameters:

  • cause: The reason for the panic.

func (*Validator) PanicMissingParam

func (v *Validator) PanicMissingParam(param string)

PanicMissingParam triggers a panic indicating that a specific parameter is missing. The panic message is formatted to include the validator's name and the missing parameter.

Parameters:

  • param: The name of the missing parameter.

func (*Validator) ValidateOptions

func (v *Validator) ValidateOptions(length int)

ValidateOptions checks if at least one option is provided. If no options are provided, it triggers a panic indicating that the "Options" parameter is missing.

Parameters:

  • length: The number of options provided.

func (*Validator) ValidateRender

func (v *Validator) ValidateRender(render any)

ValidateRender checks if a render function is provided. If the render function is nil, it triggers a panic indicating that the "Render" parameter is missing.

Parameters:

  • render: The render function to validate.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL