refactor errors

This commit is contained in:
2024-10-14 13:29:05 -05:00
parent 1e33a81a2c
commit 39d4a1e7f0
20 changed files with 398 additions and 444 deletions

View File

@@ -1,9 +1,5 @@
package core
import (
"errors"
)
type NKodePolicy struct {
MaxNkodeLen int `json:"max_nkode_len"`
MinNkodeLen int `json:"min_nkode_len"`
@@ -24,12 +20,10 @@ func NewDefaultNKodePolicy() NKodePolicy {
}
}
var InvalidNKodeLen = errors.New("invalid nkode length")
func (p *NKodePolicy) ValidLength(nkodeLen int) error {
if nkodeLen < p.MinNkodeLen || nkodeLen > p.MaxNkodeLen {
return InvalidNKodeLen
return ErrInvalidNKodeLength
}
// TODO: validate Max > Min
// Validate lockout