package password import ( "errors" "unicode/utf8" ) const ( minPasswordCodePoints = 15 maxPasswordBytes = 1024 ) var ( ErrTooShort = errors.New("password: shorter than 15 characters") ErrTooLong = errors.New("password: longer than 1024 bytes") ) func Acceptable(password string) error { if len(password) > maxPasswordBytes { return ErrTooLong } if utf8.RuneCountInString(password) < minPasswordCodePoints { return ErrTooShort } return nil }