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 ¶
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 ¶
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.