Files
blocky/internal/block/int64_component/validators/max.go
2026-02-12 20:34:32 +00:00

22 lines
480 B
Go

package int64_component_validators
import (
"blocky/internal/block/int64_component"
"fmt"
)
func Max(max int64) int64_component.Int64ComponentOption {
return func(c *int64_component.Int64ComponentConfig) {
c.Validators = append(c.Validators, func(value any) error {
s, ok := value.(int64)
if !ok {
return fmt.Errorf("provided value bust be an int: %v", value)
}
if s > max {
return fmt.Errorf("int must be %d or less", max)
}
return nil
})
}
}