-
Notifications
You must be signed in to change notification settings - Fork 44
/
params.go
42 lines (33 loc) · 1009 Bytes
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package types
import (
"fmt"
)
var (
// DefaultMaxTextLength represents the default max length for post texts
DefaultMaxTextLength uint32 = 500
)
// -------------------------------------------------------------------------------------------------------------------
// NewParams returns a new Params instance
func NewParams(maxTextLength uint32) Params {
return Params{
MaxTextLength: maxTextLength,
}
}
// DefaultParams return default paramsModule
func DefaultParams() Params {
return Params{
MaxTextLength: DefaultMaxTextLength,
}
}
// Validate perform basic checks on all parameters to ensure they are correct
func (params Params) Validate() error {
return ValidateMaxTextLength(params.MaxTextLength)
}
// -------------------------------------------------------------------------------------------------------------------
func ValidateMaxTextLength(i interface{}) error {
_, isUint32 := i.(uint32)
if !isUint32 {
return fmt.Errorf("invalid parameters type: %s", i)
}
return nil
}