add Int64Component

This commit is contained in:
2026-02-12 20:34:32 +00:00
parent 6099538fa8
commit 08682c35c1
7 changed files with 141 additions and 75 deletions

View File

@@ -0,0 +1,21 @@
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
})
}
}