vld

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package vld contains functions to interact with validators.

The package is imported like this:

import "github.com/gouniverse/base/vld"

Example

To validate a date:

vld.IsDate("2022-01-01")

To validate a datetime:

vld.IsDateTime("2022-01-01T12:00:00Z")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDate

func IsDate(value string) bool

isDate checks if a string is a valid date format

The following formats are considered valid: - YYYY-MM-DD

Business logic: - checks if the string contains 2 dashes - checks if the string does not contain colons - checks the first dash is at position 4 - checks the second dash is at position 7 - checks the string length is 10

func IsDateTime

func IsDateTime(value string) bool

isDateTime checks if a string is a valid datetime format

The following formats are condsidered valid: - YYYY-MM-DD HH:MM:SS - YYYY-MM-DDTHH:MM:SS - YYYY-MM-DDTHH:MM:SSZ

Business logic: - checks if the string contains 2 dashes - checks if the string contains 2 colons - checks the first dash is at position 4 - checks the second dash is at position 7 - checks the first colon is at position 10 - checks the second colon is at position 13 - checks the string length is 19 or 20 - checks the last character is 'Z' if the string length is 20

Types

This section is empty.

Jump to

Keyboard shortcuts

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