Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MessageSuccess = "Success" MessageInternalError = "Internal server error" MessageFailedDecodeJSON = "Failed to decode JSON" MessagePasswordInvalid = "Minimum eight characters, at least one uppercase letter, one lowercase letter, one number, and one special character" )
View Source
var ( PasswordValidation = `^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$` MinAge = 18 )
View Source
var ( CodeSuccess = "BE-000" Code4XX = "BE-4XX" Code5XX = "BE-5XX" )
View Source
var CalculateAge = func(birthdate time.Time) int { now := time.Now() age := now.Year() - birthdate.Year() if now.YearDay() < birthdate.YearDay() { age-- } return age }
View Source
var (
ID_LANG = "id"
)
View Source
var MustAbove18Rule = func(birthdate, layout string) bool { birthdateTime, err := time.Parse(layout, birthdate) if err != nil { return false } age := CalculateAge(birthdateTime) return age >= MinAge }
View Source
var PasswordValidationRule = validation.NewStringRule(func(s string) bool { if len(s) < 8 { return false } var hasUpper, hasLower, hasSpecial bool for _, char := range s { switch { case unicode.IsUpper(char): hasUpper = true case unicode.IsLower(char): hasLower = true case unicode.IsPunct(char) || unicode.IsSymbol(char): hasSpecial = true } } return hasUpper && hasLower && hasSpecial }, MessagePasswordInvalid)
Functions ¶
Types ¶
type Pagination ¶
type ResponseBody ¶
type ResponseBody struct { Code string `json:"code"` Message string `json:"message"` Pagination *Pagination `json:"pagination,omitempty"` }
Click to show internal directories.
Click to hide internal directories.