go20/day06/userapp/utils/validators.go

33 lines
750 B
Go
Raw Permalink Normal View History

// Copyright 2024 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
//
// Package utils contains utility functions.
package utils
import (
"fmt"
"strings"
)
// ValidateEmail 验证邮箱格式
func ValidateEmail(email string) bool {
return strings.Contains(email, "@")
}
// ValidateAge 验证年龄范围
func ValidateAge(age int) bool {
return age > 0 && age < 150
}
func init() {
fmt.Println("utils 包的 init 函数被调用")
}