2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-29 16:23:44 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package console
|
2018-11-29 16:23:44 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zeebo/errs"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2019-03-29 17:42:20 +00:00
|
|
|
passMinLength = 6
|
2018-11-29 16:23:44 +00:00
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// ErrValidation validation related error class.
|
2021-04-28 09:06:17 +01:00
|
|
|
var ErrValidation = errs.Class("validation")
|
2018-11-29 16:23:44 +00:00
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// ValidatePassword validates password.
|
2022-02-23 16:02:45 +00:00
|
|
|
// It returns an plain error (not wrapped in a errs.Class) if pass is invalid.
|
2019-11-25 21:36:36 +00:00
|
|
|
func ValidatePassword(pass string) error {
|
2018-12-10 15:57:06 +00:00
|
|
|
if len(pass) < passMinLength {
|
2022-02-23 16:02:45 +00:00
|
|
|
return errs.New(passwordIncorrectErrMsg, passMinLength)
|
2018-12-10 15:57:06 +00:00
|
|
|
}
|
|
|
|
|
2022-02-23 16:02:45 +00:00
|
|
|
return nil
|
2018-12-10 15:57:06 +00:00
|
|
|
}
|
2019-10-29 14:24:16 +00:00
|
|
|
|
2019-11-25 21:36:36 +00:00
|
|
|
// ValidateFullName validates full name.
|
2022-02-23 16:02:45 +00:00
|
|
|
// It returns an plain error (not wrapped in a errs.Class) if name is invalid.
|
2019-11-25 21:36:36 +00:00
|
|
|
func ValidateFullName(name string) error {
|
2019-10-29 14:24:16 +00:00
|
|
|
if name == "" {
|
|
|
|
return errs.New("full name can not be empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|