uplink/app/transcoders/options/int64_transcoder_option.go

42 lines
703 B
Go

package options
import (
"errors"
)
type Int64TranscoderOption struct {
DefaultValue int64
Required bool
Max int64
Min int64
}
func (option *Int64TranscoderOption) IsRequired() bool {
return option.Required
}
func (option *Int64TranscoderOption) Default() interface{} {
return option.DefaultValue
}
func (option *Int64TranscoderOption) Validate(value interface{}) (err error) {
intValue, ok := value.(int64)
if !ok {
err = errors.New("value is not a 64-bit integer")
return
}
if intValue > option.Max {
err = errors.New("number is too big")
return
}
if intValue < option.Min {
err = errors.New("number is too small")
return
}
err = nil
return
}