const (
// InputOTPAny accepts every character except whitespace and controls.
InputOTPAny InputOTPFilter = iota
// InputOTPDigits accepts the ASCII digits 0-9.
InputOTPDigits
// InputOTPAlphanumeric accepts the ASCII digits and letters.
InputOTPAlphanumeric
)类型 InputOTPFilter
API 文档由 Go 源码生成,内容为英文。
type InputOTPFilter uint8InputOTPFilter selects which characters a one-time code accepts, after the input-otp package's patterns: REGEXP_ONLY_DIGITS and REGEXP_ONLY_DIGITS_AND_CHARS. The zero value accepts any visible character.
常量
方法
Accepts#
func (filter InputOTPFilter) Accepts(r rune) boolAccepts reports whether the filter lets r into the code.
Normalize#
func (filter InputOTPFilter) Normalize(text string, slots int) stringNormalize is what a caller-owned editor should store after text is typed or pasted: text reduced to the characters the filter accepts and cut to slots characters (6 when slots is not positive), so a pasted "123-456" becomes "123456" for a digit code. Text that needs no change is returned as is, without allocating.