refactor db accessor

This commit is contained in:
2024-08-26 13:10:34 -05:00
parent 3bf2b4d71f
commit e6947e714d
19 changed files with 516 additions and 302 deletions

View File

@@ -1,5 +1,9 @@
package m
import (
"errors"
)
type NKodePolicy struct {
MaxNkodeLen int `json:"max_nkode_len"`
MinNkodeLen int `json:"min_nkode_len"`
@@ -19,3 +23,13 @@ func NewDefaultNKodePolicy() NKodePolicy {
Expiration: -1,
}
}
var InvalidNKodeLen = errors.New("invalid nkode length")
func (p *NKodePolicy) ValidLength(nkodeLen int) error {
if nkodeLen < p.MinNkodeLen || nkodeLen > p.MaxNkodeLen {
return InvalidNKodeLen
}
return nil
}