Documentation
¶
Index ¶
Constants ¶
const ( // OneOfKey identifies the one-of-validator to select a single value among a list of valid values used in dogu.json. OneOfKey = "ONE_OF" // BinaryMeasurementKey identifies the binary prefix validator for integer values like "1024m" used in dogu.json. BinaryMeasurementKey = "BINARY_MEASUREMENT" // FloatPercentageHundredKey identifies the float percentage validator for float values between 0 and 100% used in dogu.json. FloatPercentageHundredKey = "FLOAT_PERCENTAGE_HUNDRED" )
const (
// ValidBinaryUnits contains available binary measurement units that are manifolds of 1024.
ValidBinaryUnits = "bkmg"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryMeasurementValidator ¶
type BinaryMeasurementValidator struct {
// contains filtered or unexported fields
}
BinaryMeasurementValidator checks if the given value matches a binary measurement, f. i. '1024k'. BinaryMeasurementValidator validates only the actual config value and does not evaluate the field
ValidationDescriptor.Values
It is best to not configure the ValidationDescriptor.Values field when using this validator.
func (*BinaryMeasurementValidator) Check ¶
func (bpv *BinaryMeasurementValidator) Check(input string) error
Check checks if the input matches a zero or positive integer followed by a binary measurement, namely: b, k, m, g.
func (*BinaryMeasurementValidator) SplitValueAndUnit ¶
func (bpv *BinaryMeasurementValidator) SplitValueAndUnit(input string) (string, string)
SplitValueAndUnit returns the input's integer part as well as the binary unit. Be sure to call Check() beforehand.
type ConfigValidator ¶
type ConfigValidator struct {
// contains filtered or unexported fields
}
ConfigValidator is a Validator implementation which uses a configReader to read the values of the field.
func (*ConfigValidator) Check ¶
func (c *ConfigValidator) Check(field core.ConfigurationField) error
Check checks if a configurationField is valid.
type EntryValidator ¶
type EntryValidator interface {
// Check checks the given input from a configuration entry and returns nil if it is valid, otherwise an error.
Check(input string) error
}
EntryValidator provides a Check method to check the validity of a single configuration entry.
func CreateBinaryMeasurementValidator ¶
func CreateBinaryMeasurementValidator(core.ValidationDescriptor) EntryValidator
CreateBinaryMeasurementValidator creates a binary measurement validator that validates a single config value.
func CreateEntryValidator ¶
func CreateEntryValidator(descriptor core.ValidationDescriptor) (EntryValidator, error)
CreateEntryValidator creates the correct EntryValidator for the given descriptor.
func CreateFloatPercentageValidator ¶
func CreateFloatPercentageValidator(_ core.ValidationDescriptor) EntryValidator
CreateFloatPercentageValidator creates a float percentage measurement validator that validates a single config value.
type FloatPercentageValidator ¶
type FloatPercentageValidator struct {
// contains filtered or unexported fields
}
FloatPercentageValidator checks if the given value matches a percentage in float form, f. i. '55.50' for 55.5%. FloatPercentageValidator validates only the actual config value and does not evaluate the field ValidationDescriptor.Values It is best to not configure the ValidationDescriptor.Values field when using this validator.
func (*FloatPercentageValidator) Check ¶
func (fpv *FloatPercentageValidator) Check(input string) error
Check checks the correct regex and validates that the actual value is between 0%-100%
type Validator ¶
type Validator interface {
Check(core.ConfigurationField) error
}
Validator checks if the given configurationField is valid.