mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-02 00:11:56 +03:00
Add method for validation of the secret
This commit is contained in:
+7
-3
@@ -22,11 +22,11 @@ type Secret struct {
|
||||
}
|
||||
|
||||
func (s Secret) MarshalText() ([]byte, error) {
|
||||
if s.Key == secretEmptyKey {
|
||||
return nil, nil
|
||||
if s.Valid() {
|
||||
return []byte(s.String()), nil
|
||||
}
|
||||
|
||||
return []byte(s.String()), nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Secret) UnmarshalText(data []byte) error {
|
||||
@@ -72,6 +72,10 @@ func (s *Secret) UnmarshalText(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s Secret) Valid() bool {
|
||||
return s.Key != secretEmptyKey && s.Host != ""
|
||||
}
|
||||
|
||||
func (s Secret) String() string {
|
||||
return s.Base64()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user