validators

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateArgument

func ValidateArgument(arg string) bool

ValidateArgument checks if the provided argument contains only alphanumeric characters, underscores, slashes, or hyphens.

Parameters:

  • arg (string): The argument to validate.

Returns:

  • bool: True if the argument is valid, otherwise false.

func ValidateModuleName

func ValidateModuleName(name, directory string) error

ValidateModuleName checks if a module with the given name already exists in the specified directory.

The function constructs the expected file path for the module definition using the format "<directory>/<name>.yaml". It then checks if the file exists:

  • If the file does not exist, the function returns nil (indicating the module name is available).
  • If the file exists, it returns an error indicating that the module name is already taken.
  • If an error occurs while checking the file, it is returned.

Returns nil if the module name is available, otherwise returns an error.

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword checks if the given password meets basic validation criteria.

The function performs the following checks:

  • Trims any leading and trailing whitespace.
  • Ensures the password is not empty.
  • Ensures the password is at least 6 characters long.

Returns an error if the password is invalid, otherwise returns nil.

func ValidateVersion

func ValidateVersion(version string) error

ValidateVersion checks if the given module version is valid.

The function performs the following checks:

  • Trims any leading and trailing whitespace.
  • Ensures the version is not empty.
  • Validates the version format using a predefined regex.

Returns nil if the version is valid, otherwise returns an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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