Documentation
¶
Index ¶
- Variables
- type AllowedOperationsRule
- type DisallowRule
- type DisallowedOperationsRule
- func (d *DisallowedOperationsRule) NewInheritInstance(_ string, _ reflect.Kind, _ interface{}) (Rule, error)
- func (d *DisallowedOperationsRule) NewInstance(path string, _ reflect.Kind, _ interface{}, value string) (Rule, error)
- func (d DisallowedOperationsRule) Validate(operationSpec operation.Spec) error
- type ExpressionNotMatchError
- type ExpressionRule
- type GreaterThenError
- type LessThenError
- type MatchingKindRule
- type MatchingOperationToKindRule
- func (m *MatchingOperationToKindRule) NewInheritInstance(_ string, kind reflect.Kind, _ interface{}) (Rule, error)
- func (m *MatchingOperationToKindRule) NewInstance(_ string, kind reflect.Kind, _ interface{}, _ string) (Rule, error)
- func (m MatchingOperationToKindRule) Validate(operationSpec operation.Spec) error
- type MaxRule
- type MinRule
- type OperationNotAllowedError
- type Rule
- type TypeMismatchError
- type UnknownFieldError
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidKind = errors.New("is invalid kind") ErrInvalidBool = errors.New("is invalid bool") ErrInvalidNumber = errors.New("is invalid number") )
var ErrAddOperationTypeError = errors.New("add operation only applicable to array")
var ErrMaxRuleViolation = errors.New("value greater then specified")
var ErrOperationsNotAllowed = errors.New("operations are not allowed")
Functions ¶
This section is empty.
Types ¶
type AllowedOperationsRule ¶
AllowedOperationsRule defines witch patch operations are allowed for the field.
func (*AllowedOperationsRule) NewInheritInstance ¶
func (a *AllowedOperationsRule) NewInheritInstance(_ string, _ reflect.Kind, _ interface{}) (Rule, error)
NewInheritInstance instantiate new rule instance based on given rule.
func (*AllowedOperationsRule) NewInstance ¶
func (a *AllowedOperationsRule) NewInstance( path string, _ reflect.Kind, _ interface{}, value string, ) (Rule, error)
NewInstance instantiate new rule instance for field.
type DisallowRule ¶
type DisallowRule struct {
Disallow bool
}
DisallowRule defines if operations on field are disallowed.
func (*DisallowRule) NewInheritInstance ¶
NewInheritInstance instantiate new rule instance based on given rule.
func (*DisallowRule) NewInstance ¶
func (d *DisallowRule) NewInstance(path string, _ reflect.Kind, instance interface{}, value string) (Rule, error)
NewInstance instantiate new rule instance for field.
type DisallowedOperationsRule ¶
DisallowedOperationsRule defines witch patch operations are disallowed for the field.
func (*DisallowedOperationsRule) NewInheritInstance ¶
func (d *DisallowedOperationsRule) NewInheritInstance(_ string, _ reflect.Kind, _ interface{}) (Rule, error)
NewInheritInstance instantiate new rule instance based on given rule.
func (*DisallowedOperationsRule) NewInstance ¶
func (d *DisallowedOperationsRule) NewInstance( path string, _ reflect.Kind, _ interface{}, value string, ) (Rule, error)
NewInstance instantiate new rule instance for field.
type ExpressionNotMatchError ¶
type ExpressionNotMatchError struct {
// contains filtered or unexported fields
}
ExpressionNotMatchError indicate that given value not match expression.
func (ExpressionNotMatchError) Error ¶
func (e ExpressionNotMatchError) Error() string
type ExpressionRule ¶
ExpressionRule defines expression that needs to be matched by value. Anything is printed to string before e.g. int will be a number as string.
func (*ExpressionRule) NewInheritInstance ¶
func (e *ExpressionRule) NewInheritInstance(path string, _ reflect.Kind, instance interface{}) (Rule, error)
NewInheritInstance instantiate new rule instance based on given rule.
func (*ExpressionRule) NewInstance ¶
func (e *ExpressionRule) NewInstance(path string, _ reflect.Kind, instance interface{}, value string) (Rule, error)
NewInstance instantiate new rule instance for field.
type GreaterThenError ¶
type GreaterThenError struct {
// contains filtered or unexported fields
}
GreaterThenError indicate that a value is greater then the reference.
func (GreaterThenError) Error ¶
func (g GreaterThenError) Error() string
type LessThenError ¶
type LessThenError struct {
// contains filtered or unexported fields
}
LessThenError indicate that a value is less then the reference.
func (LessThenError) Error ¶
func (l LessThenError) Error() string
type MatchingKindRule ¶
type MatchingKindRule struct { Instance interface{} Path string }
MatchingKindRule is a default rule that is applied to all fields. This rules checks for type and name matches to prevent input for unknown fields or to violate types.
func (*MatchingKindRule) NewInheritInstance ¶
func (m *MatchingKindRule) NewInheritInstance(path string, _ reflect.Kind, instance interface{}) (Rule, error)
NewInheritInstance instantiate new rule instance based on given rule.
func (*MatchingKindRule) NewInstance ¶
func (m *MatchingKindRule) NewInstance(path string, _ reflect.Kind, instance interface{}, _ string) (Rule, error)
UseValue instantiate new rule instance for field.
type MatchingOperationToKindRule ¶ added in v1.3.1
MatchingOperationToKindRule is a default rule that is applied to all fields. This rules if operation is applyable to kind.
func (*MatchingOperationToKindRule) NewInheritInstance ¶ added in v1.3.1
func (m *MatchingOperationToKindRule) NewInheritInstance(_ string, kind reflect.Kind, _ interface{}) (Rule, error)
NewInheritInstance instantiate new rule instance based on given rule.
func (*MatchingOperationToKindRule) NewInstance ¶ added in v1.3.1
func (m *MatchingOperationToKindRule) NewInstance(_ string, kind reflect.Kind, _ interface{}, _ string) (Rule, error)
UseValue instantiate new rule instance for field.
type MaxRule ¶
type MaxRule struct {
Max float64
}
MaxRule defines the maximum size/value:
- Applies on len for Array, Chan, Map, Slice and String.
- Applies on value for any numeric type.
func (*MaxRule) NewInheritInstance ¶
NewInheritInstance instantiate new rule instance based on given rule.
type MinRule ¶
type MinRule struct {
Min float64
}
MinRule defines the minimum size/value:
- Applies on len for Array, Chan, Map, Slice and String.
- Applies on value for any numeric type.
func (*MinRule) NewInheritInstance ¶
NewInheritInstance instantiate new rule instance based on given rule.
type OperationNotAllowedError ¶
type OperationNotAllowedError struct {
// contains filtered or unexported fields
}
OperationNotAllowedError indicate that a given JSON patch operation is not allowed.
func (OperationNotAllowedError) Error ¶
func (o OperationNotAllowedError) Error() string
type Rule ¶
type Rule interface { NewInstance(patch string, kind reflect.Kind, instance interface{}, value string) (Rule, error) NewInheritInstance(patch string, kind reflect.Kind, instance interface{}) (Rule, error) Validate(operationSpec operation.Spec) error }
Rule defines the interface for a patch operation rule.
type TypeMismatchError ¶
type TypeMismatchError struct {
// contains filtered or unexported fields
}
TypeMismatchError indicate that a given type not match a reference.
func (TypeMismatchError) Error ¶
func (t TypeMismatchError) Error() string
type UnknownFieldError ¶
type UnknownFieldError struct {
// contains filtered or unexported fields
}
UnknownFieldError indicate that a field is not known.
func (UnknownFieldError) Error ¶
func (u UnknownFieldError) Error() string