format

package
v0.0.0-...-57ed434 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: AGPL-3.0 Imports: 9 Imported by: 12

Documentation

Index

Constants

View Source
const (
	EmailPattern               = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*` //用户邮箱
	PasswordPattern            = `^[a-zA-Z]\w{5,17}$`                          //用户密码
	UserNamePattern            = "^[ 0-9A-Za-z-_]{1,40}$"                      //用户名
	OrgNamePattern             = "^[\u4e00-\u9fa5|0-9|a-zA-Z]{1,20}$"          //组织名
	OrgCodePattern             = "^[0-9|a-zA-Z]{1,20}$"                        //网址后缀编号
	OrgAdressPattern           = `^.{0,100}$`                                  //组织地址
	ProjectNamePattern         = `^.{1,30}$`                                   //项目名
	ProjectPreviousCodePattern = `^[a-zA-Z|0-9]{1,50}$`                        //项目前缀编号
	ProjectRemarkPattern       = `^[\s\S]{0,500}$`                             //项目描述(简介)
	//ProjectNoticePattern       = `^.{0,2000}$`                                 //项目公告
	IssueNamePattern = `^(.|\n){0,500}$` //任务名 允许换行符
	//IssueRemarkPattern           = `^.{0,10000}$`                                //任务描述(详情)
	IssueCommenPattern           = `^.{0,10000}$` //任务评论
	ProjectObjectTypeNamePattern = `^.{1,30}$`    //标题栏名
	ProjectTableNamePattern      = `^.{1,200}$`   // 项目表名
	//ResourceNamePattern          = `^[^\\\\/:*?\"<>|]{1,300}(\.[a-zA-Z0-9]+)?$` //资源名
	ResourceNamePattern            = `^.{1,300}$`                                                                 //资源名
	FolderNamePattern              = `^[^\\\\/:*?\"<>|]{1,30}$`                                                   //文件夹名
	RoleNamePattern                = "^[a-zA-Z|0-9]{1,20}$"                                                       //角色名
	NumFloat1                      = `^([1-9]\d{0,9}|0)(\.\d)?$`                                                  //小数点后一位
	SqlFieldPattern                = `(^_([a-zA-Z0-9]_?)*$)|(^[a-zA-Z](_?[a-zA-Z0-9])*_?$)`                       //数字、字母、下划线
	ChinaPhoneWithAreaFlagPattern  = `\+86\ 1[0-9]{10}`                                                           //带区号的中国手机号。如:`+86 15010111001`
	ChinaPhoneWithoutAreaPattern   = `1[0-9]{10}`                                                                 //不带区号的中国手机号。如:`15010111001`
	ForeignPhoneWithoutAreaPattern = `[0-9]{3,15}`                                                                //不带区号的国际手机号。一定是数值,并且一般不超过 15 位
	PhoneRegionCodePattern         = `\+\d{1,4}`                                                                  // 国际的手机号码归属地 code
	WebLinkPattern                 = `^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$` // web 链接

	IssueCommentMemberPattern = "\\#\\[([\u4E00-\u9FA5A-Za-z0-9_]{0,})\\:\\d+\\]\\&\\$" // @成员 评论内容提取成员名字,如:@#[小牟:29520]&$
)
View Source
const (
	ChinesePattern  = "[\u4e00-\u9fa5]+?"
	AllBlankPattern = "^ +$"
)

Variables

This section is empty.

Functions

func CheckTimeRangeLimitDayNumValid

func CheckTimeRangeLimitDayNumValid(startTime, endTime, limitDay int64) bool

检查起止日期内,天数是否超过限制

func CheckTimeRangeTimeNumIsValid

func CheckTimeRangeTimeNumIsValid(secondsNum int64, startTime, endTime int64) bool

检查时间段间的时间,是否合法。不能超过。

func FormatFloatWithoutZero

func FormatFloatWithoutZero(num float64, decimal int) string

保留n位小数,并去除小数点后无效的 0。 主要逻辑就是先乘,trunc之后再除回去,就达到了保留N位小数的效果 来自于 https://www.jianshu.com/p/ddec820bc4a4

func FormatNeedTimeIntoSecondNumber

func FormatNeedTimeIntoSecondNumber(hourStr string) int64

前端输入的小时数转换为秒数

func FormatNeedTimeIntoString

func FormatNeedTimeIntoString(secondNum int64) string

数据库中的数值转为浮点数的小时数,再转为字符串,传给前端。 当浮点数为 `0.0` 时,强制为 `0`

func Round

func Round(f float64, n int) float64

浮点数保留 n 位有效小数。

func TransformTimeStampToDate

func TransformTimeStampToDate(timeStamp int64) string

将时间戳转换为年月日字符串

func VerifyChinaPhoneFormat

func VerifyChinaPhoneFormat(phone string) bool

VerifyChinaPhoneFormat 校验是否是合法的中文手机号码

func VerifyChinaPhoneWithoutAreaFormat

func VerifyChinaPhoneWithoutAreaFormat(phone string) bool

VerifyChinaPhoneWithoutAreaFormat 校验是否是合法的中文手机号码,不带国家代码

func VerifyDepartmentName

func VerifyDepartmentName(name string) bool

func VerifyEmailFormat

func VerifyEmailFormat(emails ...string) bool

func VerifyFloat1

func VerifyFloat1(input string) bool

验证,小数点后只允许一位

func VerifyFolderNameFormat

func VerifyFolderNameFormat(input string) bool

文件夹名

func VerifyForeignPhoneNumberFormat

func VerifyForeignPhoneNumberFormat(phone string) bool

func VerifyIssueCommenFormat

func VerifyIssueCommenFormat(input string) bool

任务评论

func VerifyIssueNameFormat

func VerifyIssueNameFormat(input string) bool

任务名

func VerifyIssueRemarkFormat

func VerifyIssueRemarkFormat(input string) bool

任务简介

func VerifyOrgAdressFormat

func VerifyOrgAdressFormat(input string) bool

详细地址

func VerifyOrgCodeFormat

func VerifyOrgCodeFormat(input string) bool

网址后缀

func VerifyOrgNameFormat

func VerifyOrgNameFormat(input string) bool

组织名

func VerifyPhoneRegionFormat

func VerifyPhoneRegionFormat(regionCode string) bool

VerifyPhoneRegionFormat 验证手机归属地 code 格式

func VerifyProjectNameFormat

func VerifyProjectNameFormat(input string) bool

项目名

func VerifyProjectNoticeFormat

func VerifyProjectNoticeFormat(input string) bool

项目公告

func VerifyProjectObjectTypeNameFormat

func VerifyProjectObjectTypeNameFormat(input string) bool

任务栏名字

func VerifyProjectPreviousCodeFormat

func VerifyProjectPreviousCodeFormat(input string) bool

项目前缀编号

func VerifyProjectRemarkFormat

func VerifyProjectRemarkFormat(input string) bool

项目简介

func VerifyPwdFormat

func VerifyPwdFormat(password string) bool

func VerifyResourceNameFormat

func VerifyResourceNameFormat(input string) bool

资源名

func VerifyRoleNameFormat

func VerifyRoleNameFormat(input string) bool

角色名

func VerifySqlFieldFormat

func VerifySqlFieldFormat(input string) bool

字段判断

func VerifyTableNameFormat

func VerifyTableNameFormat(name string) bool

表名

func VerifyUserNameFormat

func VerifyUserNameFormat(input string) bool

用户名

func VerifyWebLinkFormat

func VerifyWebLinkFormat(str string) bool

VerifyWebLinkFormat 校验是否是 web 链接

Types

This section is empty.

Jump to

Keyboard shortcuts

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