Documentation
¶
Index ¶
- Variables
- func DeepClone(value interface{}) (interface{}, error)
- func IsMutationOp(opType internal.OpType) bool
- func IsPredicateOp(opType internal.OpType) bool
- func IsSecondOrderPredicateOp(opType internal.OpType) bool
- type BaseOp
- type Op
- type OpAddOperation
- func (o *OpAddOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpAddOperation) Code() int
- func (o *OpAddOperation) Op() internal.OpType
- func (o *OpAddOperation) Path() []string
- func (o *OpAddOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpAddOperation) ToJSON() (internal.Operation, error)
- func (o *OpAddOperation) Validate() error
- type OpAndOperation
- func (o *OpAndOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpAndOperation) Code() int
- func (o *OpAndOperation) Not() bool
- func (o *OpAndOperation) Op() internal.OpType
- func (o *OpAndOperation) Ops() []internal.PredicateOp
- func (o *OpAndOperation) Path() []string
- func (o *OpAndOperation) Test(doc interface{}) (bool, error)
- func (o *OpAndOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpAndOperation) ToJSON() (internal.Operation, error)
- func (o *OpAndOperation) Validate() error
- type OpContainsOperation
- func (op *OpContainsOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpContainsOperation) Code() int
- func (op *OpContainsOperation) Not() bool
- func (op *OpContainsOperation) Op() internal.OpType
- func (op *OpContainsOperation) Path() []string
- func (op *OpContainsOperation) Test(doc any) (bool, error)
- func (op *OpContainsOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpContainsOperation) ToJSON() (internal.Operation, error)
- func (op *OpContainsOperation) Validate() error
- type OpCopyOperation
- func (o *OpCopyOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpCopyOperation) Code() int
- func (o *OpCopyOperation) From() []string
- func (o *OpCopyOperation) Op() internal.OpType
- func (o *OpCopyOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpCopyOperation) ToJSON() (internal.Operation, error)
- func (o *OpCopyOperation) Validate() error
- type OpDefinedOperation
- func (o *OpDefinedOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpDefinedOperation) Code() int
- func (o *OpDefinedOperation) Not() bool
- func (o *OpDefinedOperation) Op() internal.OpType
- func (op *OpDefinedOperation) Path() []string
- func (o *OpDefinedOperation) Test(doc interface{}) (bool, error)
- func (o *OpDefinedOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpDefinedOperation) ToJSON() (internal.Operation, error)
- func (o *OpDefinedOperation) Validate() error
- type OpEndsOperation
- func (op *OpEndsOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpEndsOperation) Code() int
- func (op *OpEndsOperation) Op() internal.OpType
- func (op *OpEndsOperation) Path() []string
- func (op *OpEndsOperation) Test(doc any) (bool, error)
- func (op *OpEndsOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpEndsOperation) ToJSON() (internal.Operation, error)
- func (op *OpEndsOperation) Validate() error
- type OpExtendOperation
- func (o *OpExtendOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpExtendOperation) Code() int
- func (op *OpExtendOperation) Op() internal.OpType
- func (o *OpExtendOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpExtendOperation) ToJSON() (internal.Operation, error)
- func (op *OpExtendOperation) Validate() error
- type OpFlipOperation
- func (op *OpFlipOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpFlipOperation) Code() int
- func (op *OpFlipOperation) Op() internal.OpType
- func (op *OpFlipOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpFlipOperation) ToJSON() (internal.Operation, error)
- func (op *OpFlipOperation) Validate() error
- type OpInOperation
- func (op *OpInOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpInOperation) Code() int
- func (op *OpInOperation) Not() bool
- func (op *OpInOperation) Op() internal.OpType
- func (op *OpInOperation) Path() []string
- func (op *OpInOperation) Test(doc any) (bool, error)
- func (op *OpInOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpInOperation) ToJSON() (internal.Operation, error)
- func (op *OpInOperation) Validate() error
- type OpIncOperation
- func (op *OpIncOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpIncOperation) Code() int
- func (op *OpIncOperation) Op() internal.OpType
- func (op *OpIncOperation) Path() []string
- func (op *OpIncOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpIncOperation) ToJSON() (internal.Operation, error)
- func (op *OpIncOperation) Validate() error
- type OpLessOperation
- func (op *OpLessOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpLessOperation) Code() int
- func (op *OpLessOperation) Not() bool
- func (op *OpLessOperation) Op() internal.OpType
- func (op *OpLessOperation) Path() []string
- func (op *OpLessOperation) Test(doc any) (bool, error)
- func (op *OpLessOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpLessOperation) ToJSON() (internal.Operation, error)
- func (op *OpLessOperation) Validate() error
- type OpMatchesOperation
- func (o *OpMatchesOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpMatchesOperation) Code() int
- func (o *OpMatchesOperation) Op() internal.OpType
- func (o *OpMatchesOperation) Path() []string
- func (o *OpMatchesOperation) Test(doc interface{}) (bool, error)
- func (o *OpMatchesOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpMatchesOperation) ToJSON() (internal.Operation, error)
- func (o *OpMatchesOperation) Validate() error
- type OpMergeOperation
- func (op *OpMergeOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpMergeOperation) Code() int
- func (op *OpMergeOperation) Op() internal.OpType
- func (op *OpMergeOperation) Path() []string
- func (op *OpMergeOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpMergeOperation) ToJSON() (internal.Operation, error)
- func (op *OpMergeOperation) Validate() error
- type OpMoreOperation
- func (o *OpMoreOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpMoreOperation) Code() int
- func (o *OpMoreOperation) Op() internal.OpType
- func (o *OpMoreOperation) Path() []string
- func (o *OpMoreOperation) Test(doc interface{}) (bool, error)
- func (o *OpMoreOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpMoreOperation) ToJSON() (internal.Operation, error)
- func (o *OpMoreOperation) Validate() error
- type OpMoveOperation
- func (o *OpMoveOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpMoveOperation) Code() int
- func (o *OpMoveOperation) From() []string
- func (o *OpMoveOperation) Op() internal.OpType
- func (o *OpMoveOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpMoveOperation) ToJSON() (internal.Operation, error)
- func (o *OpMoveOperation) Validate() error
- type OpNotOperation
- func (o *OpNotOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpNotOperation) Code() int
- func (o *OpNotOperation) Not() bool
- func (o *OpNotOperation) Op() internal.OpType
- func (o *OpNotOperation) Ops() []internal.PredicateOp
- func (o *OpNotOperation) Path() []string
- func (o *OpNotOperation) Test(doc any) (bool, error)
- func (o *OpNotOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpNotOperation) ToJSON() (internal.Operation, error)
- func (o *OpNotOperation) Validate() error
- type OpOrOperation
- func (o *OpOrOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpOrOperation) Code() int
- func (o *OpOrOperation) Not() bool
- func (o *OpOrOperation) Op() internal.OpType
- func (o *OpOrOperation) Ops() []internal.PredicateOp
- func (o *OpOrOperation) Path() []string
- func (o *OpOrOperation) Test(doc interface{}) (bool, error)
- func (o *OpOrOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpOrOperation) ToJSON() (internal.Operation, error)
- func (o *OpOrOperation) Validate() error
- type OpRemoveOperation
- func (o *OpRemoveOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpRemoveOperation) Code() int
- func (o *OpRemoveOperation) Op() internal.OpType
- func (o *OpRemoveOperation) Path() []string
- func (o *OpRemoveOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpRemoveOperation) ToJSON() (internal.Operation, error)
- func (o *OpRemoveOperation) Validate() error
- type OpReplaceOperation
- func (o *OpReplaceOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpReplaceOperation) Code() int
- func (o *OpReplaceOperation) Op() internal.OpType
- func (o *OpReplaceOperation) Path() []string
- func (o *OpReplaceOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpReplaceOperation) ToJSON() (internal.Operation, error)
- func (o *OpReplaceOperation) Validate() error
- type OpResult
- type OpSplitOperation
- func (op *OpSplitOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpSplitOperation) Code() int
- func (op *OpSplitOperation) Op() internal.OpType
- func (op *OpSplitOperation) Path() []string
- func (op *OpSplitOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpSplitOperation) ToJSON() (internal.Operation, error)
- func (op *OpSplitOperation) Validate() error
- type OpStartsOperation
- func (op *OpStartsOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpStartsOperation) Code() int
- func (op *OpStartsOperation) Op() internal.OpType
- func (op *OpStartsOperation) Path() []string
- func (op *OpStartsOperation) Test(doc any) (bool, error)
- func (op *OpStartsOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpStartsOperation) ToJSON() (internal.Operation, error)
- func (op *OpStartsOperation) Validate() error
- type OpStrDelOperation
- func (o *OpStrDelOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpStrDelOperation) Code() int
- func (op *OpStrDelOperation) Op() internal.OpType
- func (o *OpStrDelOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpStrDelOperation) ToJSON() (internal.Operation, error)
- func (op *OpStrDelOperation) Validate() error
- type OpStrInsOperation
- func (op *OpStrInsOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpStrInsOperation) Code() int
- func (op *OpStrInsOperation) Op() internal.OpType
- func (op *OpStrInsOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpStrInsOperation) ToJSON() (internal.Operation, error)
- func (op *OpStrInsOperation) Validate() error
- type OpTestOperation
- func (o *OpTestOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpTestOperation) Code() int
- func (o *OpTestOperation) Not() bool
- func (o *OpTestOperation) Op() internal.OpType
- func (o *OpTestOperation) Path() []string
- func (o *OpTestOperation) Test(doc interface{}) (bool, error)
- func (o *OpTestOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpTestOperation) ToJSON() (internal.Operation, error)
- func (o *OpTestOperation) Validate() error
- type OpTestStringLenOperation
- func (op *OpTestStringLenOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpTestStringLenOperation) Code() int
- func (op *OpTestStringLenOperation) Op() internal.OpType
- func (op *OpTestStringLenOperation) Path() []string
- func (op *OpTestStringLenOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpTestStringLenOperation) ToJSON() (internal.Operation, error)
- func (op *OpTestStringLenOperation) Validate() error
- type OpTestStringOperation
- func (op *OpTestStringOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpTestStringOperation) Code() int
- func (op *OpTestStringOperation) Op() internal.OpType
- func (op *OpTestStringOperation) Path() []string
- func (op *OpTestStringOperation) Test(doc any) (bool, error)
- func (op *OpTestStringOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpTestStringOperation) ToJSON() (internal.Operation, error)
- func (op *OpTestStringOperation) Validate() error
- type OpTestTypeOperation
- func (op *OpTestTypeOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpTestTypeOperation) Code() int
- func (op *OpTestTypeOperation) Not() bool
- func (op *OpTestTypeOperation) Op() internal.OpType
- func (op *OpTestTypeOperation) Path() []string
- func (op *OpTestTypeOperation) Test(doc any) (bool, error)
- func (op *OpTestTypeOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpTestTypeOperation) ToJSON() (internal.Operation, error)
- func (op *OpTestTypeOperation) Validate() error
- type OpTypeOperation
- func (op *OpTypeOperation) Apply(doc any) (internal.OpResult[any], error)
- func (op *OpTypeOperation) Code() int
- func (op *OpTypeOperation) Not() bool
- func (op *OpTypeOperation) Op() internal.OpType
- func (op *OpTypeOperation) Path() []string
- func (op *OpTypeOperation) Test(doc any) (bool, error)
- func (op *OpTypeOperation) ToCompact() (internal.CompactOperation, error)
- func (op *OpTypeOperation) ToJSON() (internal.Operation, error)
- func (op *OpTypeOperation) Validate() error
- type OpUndefinedOperation
- func (o *OpUndefinedOperation) Apply(doc any) (internal.OpResult[any], error)
- func (o *OpUndefinedOperation) Code() int
- func (o *OpUndefinedOperation) Not() bool
- func (o *OpUndefinedOperation) Op() internal.OpType
- func (o *OpUndefinedOperation) Path() []string
- func (o *OpUndefinedOperation) Test(doc interface{}) (bool, error)
- func (o *OpUndefinedOperation) ToCompact() (internal.CompactOperation, error)
- func (o *OpUndefinedOperation) ToJSON() (internal.Operation, error)
- func (o *OpUndefinedOperation) Validate() error
- type PredicateOp
- type PredicateOpBase
- type SecondOrderPredicateOp
Constants ¶
This section is empty.
Variables ¶
var ( // Core path errors ErrPathNotFound = errors.New("path not found") ErrPathDoesNotExist = errors.New("path does not exist") ErrInvalidPath = errors.New("invalid path") ErrPathEmpty = errors.New("path cannot be empty") ErrFromPathEmpty = errors.New("from path cannot be empty") ErrPathsIdentical = errors.New("path and from cannot be the same") // Array operation errors ErrArrayIndexOutOfBounds = errors.New("array index out of bounds") ErrIndexOutOfRange = errors.New("index out of range") ErrNotAnArray = errors.New("not an array") ErrArrayTooSmall = errors.New("array must have at least 2 elements") ErrPositionOutOfBounds = errors.New("position out of bounds") ErrPositionNegative = errors.New("position cannot be negative") // Type validation errors ErrNotString = errors.New("value is not a string") ErrNotNumber = errors.New("value is not a number") ErrNotObject = errors.New("value is not an object") ErrInvalidType = errors.New("invalid type") ErrEmptyTypeList = errors.New("types cannot be empty") // Operation execution errors ErrTestFailed = errors.New("test failed") ErrDefinedTestFailed = errors.New("defined test failed") ErrUndefinedTestFailed = errors.New("undefined test failed") ErrAndTestFailed = errors.New("and test failed") ErrOrTestFailed = errors.New("or test failed") ErrNotTestFailed = errors.New("not test failed") // Value operation errors ErrCannotReplace = errors.New("cannot replace key in non-object") ErrCannotAddToValue = errors.New("cannot add to non-object/non-array value") ErrCannotRemoveFromValue = errors.New("cannot remove from non-object/non-array document") ErrPathMissingRecursive = errors.New("path does not exist -- missing objects are not created recursively") ErrCannotMoveIntoChildren = errors.New("cannot move into own children") ErrPropertiesNil = errors.New("properties cannot be nil") ErrValuesArrayEmpty = errors.New("values array cannot be empty") // Key type errors ErrInvalidKeyTypeMap = errors.New("invalid key type for map") ErrInvalidKeyTypeSlice = errors.New("invalid key type for slice") ErrUnsupportedParentType = errors.New("unsupported parent type") // String operation errors ErrPositionOutOfStringRange = errors.New("position out of range") ErrSubstringTooLong = errors.New("substring extends beyond string length") ErrSubstringMismatch = errors.New("substring does not match") ErrStringLengthMismatch = errors.New("string length mismatch") ErrPatternEmpty = errors.New("pattern cannot be empty") ErrLengthNegative = errors.New("length cannot be negative") // Type comparison errors ErrTypeMismatch = errors.New("type mismatch") // Predicate operation errors ErrInvalidPredicateInAnd = errors.New("invalid predicate operation in AND") ErrInvalidPredicateInNot = errors.New("invalid predicate operation in NOT") ErrInvalidPredicateInOr = errors.New("invalid predicate operation in OR") ErrAndNoOperands = errors.New("and operation must have at least one operand") ErrNotNoOperands = errors.New("not operation must have at least one operand") ErrOrNoOperands = errors.New("or operation must have at least one operand") // Operation modification errors ErrCannotModifyRootArray = errors.New("cannot modify root array directly") ErrCannotUpdateParent = errors.New("cannot update parent") ErrCannotUpdateGrandparent = errors.New("cannot update grandparent") ErrCannotAppendInPlace = errors.New("cannot append to slice in place - caller must handle") ErrSliceDeletionNotSupported = errors.New("slice deletion not supported in place - caller must handle") ErrKeyDoesNotExist = errors.New("key does not exist") // Value conversion errors ErrCannotConvertNilToString = errors.New("cannot convert nil to string") // Test operation errors ErrTestOperationNumberStringMismatch = errors.New("test operation failed: number is not equal to string") ErrTestOperationStringNotEquivalent = errors.New("test operation failed: string not equivalent") // Base errors for dynamic wrapping with fmt.Errorf ErrComparisonFailed = errors.New("comparison failed") ErrStringMismatch = errors.New("string mismatch") ErrTestOperationFailed = errors.New("test operation failed") ErrInvalidIndex = errors.New("invalid index") ErrRegexPattern = errors.New("regex pattern error") ErrOperationFailed = errors.New("operation failed") )
Sentinel errors for path and validation related operations
Functions ¶
func DeepClone ¶
func DeepClone(value interface{}) (interface{}, error)
DeepClone performs a deep clone of a value.
func IsMutationOp ¶
IsMutationOp checks if an operation type is a mutation operation.
func IsPredicateOp ¶
IsPredicateOp checks if an operation type is a predicate operation.
func IsSecondOrderPredicateOp ¶
IsSecondOrderPredicateOp checks if an operation type is a second-order predicate operation.
Types ¶
type BaseOp ¶
type BaseOp struct {
// contains filtered or unexported fields
}
BaseOp provides common functionality for all operations.
func NewBaseOpWithFrom ¶
NewBaseOpWithFrom creates a new BaseOp with path and from path.
type OpAddOperation ¶
type OpAddOperation struct {
BaseOp
Value interface{} `json:"value"` // Value to add
}
OpAddOperation represents an add operation that adds a value at a specified path.
func NewOpAddOperation ¶
func NewOpAddOperation(path []string, value interface{}) *OpAddOperation
NewOpAddOperation creates a new OpAddOperation operation.
func (*OpAddOperation) Op ¶
func (o *OpAddOperation) Op() internal.OpType
Op returns the operation type.
func (*OpAddOperation) Path ¶
func (o *OpAddOperation) Path() []string
Path returns the operation path.
func (*OpAddOperation) ToCompact ¶
func (o *OpAddOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpAddOperation) ToJSON ¶
func (o *OpAddOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpAddOperation) Validate ¶
func (o *OpAddOperation) Validate() error
Validate validates the add operation.
type OpAndOperation ¶
type OpAndOperation struct {
BaseOp
Operations []interface{} `json:"ops"` // Array of operations
}
OpAndOperation represents an AND operation that combines multiple predicate operations.
func NewOpAndOperation ¶
func NewOpAndOperation(path []string, ops []interface{}) *OpAndOperation
NewOpAndOperation creates a new OpAndOperation operation.
func (*OpAndOperation) Not ¶
func (o *OpAndOperation) Not() bool
Not returns false since this is not a NOT operation.
func (*OpAndOperation) Op ¶
func (o *OpAndOperation) Op() internal.OpType
Op returns the operation type.
func (*OpAndOperation) Ops ¶
func (o *OpAndOperation) Ops() []internal.PredicateOp
Ops returns the predicate operations.
func (*OpAndOperation) Path ¶
func (o *OpAndOperation) Path() []string
func (*OpAndOperation) Test ¶
func (o *OpAndOperation) Test(doc interface{}) (bool, error)
Test performs the AND operation.
func (*OpAndOperation) ToCompact ¶
func (o *OpAndOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpAndOperation) ToJSON ¶
func (o *OpAndOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpAndOperation) Validate ¶
func (o *OpAndOperation) Validate() error
Validate validates the AND operation.
type OpContainsOperation ¶
type OpContainsOperation struct {
BaseOp
Value string `json:"value"` // Substring to search for
IgnoreCase bool `json:"ignore_case"` // Whether to ignore case when comparing
}
OpContainsOperation represents a test operation that checks if a string value contains a substring.
func NewOpContainsOperation ¶
func NewOpContainsOperation(path []string, substring string) *OpContainsOperation
NewOpContainsOperation creates a new OpContainsOperation operation.
func NewOpContainsOperationWithIgnoreCase ¶
func NewOpContainsOperationWithIgnoreCase(path []string, substring string, ignoreCase bool) *OpContainsOperation
NewOpContainsOperationWithIgnoreCase creates a new OpContainsOperation operation with ignore case option.
func (*OpContainsOperation) Code ¶
func (op *OpContainsOperation) Code() int
Code returns the operation code.
func (*OpContainsOperation) Not ¶
func (op *OpContainsOperation) Not() bool
Not returns false (contains operation doesn't support not modifier).
func (*OpContainsOperation) Op ¶
func (op *OpContainsOperation) Op() internal.OpType
Op returns the operation type.
func (*OpContainsOperation) Path ¶
func (op *OpContainsOperation) Path() []string
func (*OpContainsOperation) Test ¶
func (op *OpContainsOperation) Test(doc any) (bool, error)
Test performs the contains test operation.
func (*OpContainsOperation) ToCompact ¶
func (op *OpContainsOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpContainsOperation) ToJSON ¶
func (op *OpContainsOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpContainsOperation) Validate ¶
func (op *OpContainsOperation) Validate() error
Validate validates the contains operation.
type OpCopyOperation ¶
OpCopyOperation represents a copy operation that copies a value from one path to another.
func NewOpCopyOperation ¶
func NewOpCopyOperation(path, from []string) *OpCopyOperation
NewOpCopyOperation creates a new OpCopyOperation operation.
func (*OpCopyOperation) Code ¶
func (o *OpCopyOperation) Code() int
Code returns the operation code.
func (*OpCopyOperation) From ¶
func (o *OpCopyOperation) From() []string
From returns the source path.
func (*OpCopyOperation) Op ¶
func (o *OpCopyOperation) Op() internal.OpType
Op returns the operation type.
func (*OpCopyOperation) ToCompact ¶
func (o *OpCopyOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpCopyOperation) ToJSON ¶
func (o *OpCopyOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpCopyOperation) Validate ¶
func (o *OpCopyOperation) Validate() error
Validate validates the copy operation.
type OpDefinedOperation ¶
type OpDefinedOperation struct {
BaseOp
}
OpDefinedOperation represents a test operation that checks if a path is defined.
func NewOpDefinedOperation ¶
func NewOpDefinedOperation(path []string) *OpDefinedOperation
NewOpDefinedOperation creates a new OpDefinedOperation operation.
func (*OpDefinedOperation) Code ¶
func (o *OpDefinedOperation) Code() int
Code returns the operation code.
func (*OpDefinedOperation) Not ¶
func (o *OpDefinedOperation) Not() bool
Not returns false (defined operation doesn't support not modifier).
func (*OpDefinedOperation) Op ¶
func (o *OpDefinedOperation) Op() internal.OpType
Op returns the operation type.
func (*OpDefinedOperation) Path ¶
func (op *OpDefinedOperation) Path() []string
func (*OpDefinedOperation) Test ¶
func (o *OpDefinedOperation) Test(doc interface{}) (bool, error)
Test performs the defined operation.
func (*OpDefinedOperation) ToCompact ¶
func (o *OpDefinedOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpDefinedOperation) ToJSON ¶
func (o *OpDefinedOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpDefinedOperation) Validate ¶
func (o *OpDefinedOperation) Validate() error
Validate validates the defined operation.
type OpEndsOperation ¶
type OpEndsOperation struct {
BaseOp
Value string `json:"value"` // Expected suffix
IgnoreCase bool `json:"ignore_case"` // Whether to ignore case
}
OpEndsOperation represents a test operation that checks if a string value ends with a specific suffix.
func NewOpEndsOperation ¶
func NewOpEndsOperation(path []string, suffix string) *OpEndsOperation
NewOpEndsOperation creates a new OpEndsOperation operation.
func NewOpEndsOperationWithIgnoreCase ¶
func NewOpEndsOperationWithIgnoreCase(path []string, suffix string, ignoreCase bool) *OpEndsOperation
NewOpEndsOperationWithIgnoreCase creates a new OpEndsOperation operation with ignore case option.
func (*OpEndsOperation) Code ¶
func (op *OpEndsOperation) Code() int
Code returns the operation code.
func (*OpEndsOperation) Op ¶
func (op *OpEndsOperation) Op() internal.OpType
Op returns the operation type.
func (*OpEndsOperation) Path ¶
func (op *OpEndsOperation) Path() []string
Path returns the operation path.
func (*OpEndsOperation) Test ¶
func (op *OpEndsOperation) Test(doc any) (bool, error)
Test evaluates the ends predicate condition.
func (*OpEndsOperation) ToCompact ¶
func (op *OpEndsOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpEndsOperation) ToJSON ¶
func (op *OpEndsOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpEndsOperation) Validate ¶
func (op *OpEndsOperation) Validate() error
Validate validates the ends operation.
type OpExtendOperation ¶
type OpExtendOperation struct {
BaseOp
Properties map[string]interface{} `json:"props"` // Properties to add
DeleteNull bool `json:"deleteNull"` // Whether to delete null properties
}
OpExtendOperation represents an object extend operation. path: target path props: properties to add/update deleteNull: whether to delete properties with null values Only supports object type fields.
func NewOpExtendOperation ¶
func NewOpExtendOperation(path []string, properties map[string]interface{}, deleteNull bool) *OpExtendOperation
NewOpExtendOperation creates a new object extend operation.
func (*OpExtendOperation) Code ¶
func (op *OpExtendOperation) Code() int
Code returns the operation code.
func (*OpExtendOperation) Op ¶
func (op *OpExtendOperation) Op() internal.OpType
Op returns the operation type.
func (*OpExtendOperation) ToCompact ¶
func (o *OpExtendOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpExtendOperation) ToJSON ¶
func (o *OpExtendOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpExtendOperation) Validate ¶
func (op *OpExtendOperation) Validate() error
Validate validates the extend operation.
type OpFlipOperation ¶
type OpFlipOperation struct {
BaseOp
}
OpFlipOperation represents a flip operation that inverts boolean values or converts other types to boolean and then inverts them
func NewOpFlipOperation ¶
func NewOpFlipOperation(path []string) *OpFlipOperation
NewOpFlipOperation creates a new flip operation
func (*OpFlipOperation) Code ¶
func (op *OpFlipOperation) Code() int
Code returns the operation code
func (*OpFlipOperation) Op ¶
func (op *OpFlipOperation) Op() internal.OpType
Op returns the operation type
func (*OpFlipOperation) ToCompact ¶
func (op *OpFlipOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpFlipOperation) ToJSON ¶
func (op *OpFlipOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpFlipOperation) Validate ¶
func (op *OpFlipOperation) Validate() error
Validate validates the flip operation.
type OpInOperation ¶
type OpInOperation struct {
BaseOp
Values []interface{} `json:"values"` // Array of values to check against
}
OpInOperation represents a test operation that checks if a value is present in a specified array.
func NewOpInOperation ¶
func NewOpInOperation(path []string, values []interface{}) *OpInOperation
NewOpInOperation creates a new OpInOperation operation.
func (*OpInOperation) Not ¶
func (op *OpInOperation) Not() bool
Not returns false since this is not a NOT operation.
func (*OpInOperation) Op ¶
func (op *OpInOperation) Op() internal.OpType
Op returns the operation type.
func (*OpInOperation) Path ¶
func (op *OpInOperation) Path() []string
Path returns the operation path.
func (*OpInOperation) Test ¶
func (op *OpInOperation) Test(doc any) (bool, error)
Test evaluates the in predicate condition.
func (*OpInOperation) ToCompact ¶
func (op *OpInOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpInOperation) ToJSON ¶
func (op *OpInOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpInOperation) Validate ¶
func (op *OpInOperation) Validate() error
Validate validates the in operation.
type OpIncOperation ¶
OpIncOperation represents an increment operation that increments a numeric value.
func NewOpIncOperation ¶
func NewOpIncOperation(path []string, inc float64) *OpIncOperation
NewOpIncOperation creates a new OpIncOperation operation.
func (*OpIncOperation) Op ¶
func (op *OpIncOperation) Op() internal.OpType
Op returns the operation type.
func (*OpIncOperation) Path ¶
func (op *OpIncOperation) Path() []string
Path returns the operation path.
func (*OpIncOperation) ToCompact ¶
func (op *OpIncOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpIncOperation) ToJSON ¶
func (op *OpIncOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpIncOperation) Validate ¶
func (op *OpIncOperation) Validate() error
Validate validates the increment operation.
type OpLessOperation ¶
OpLessOperation represents a test operation that checks if a numeric value is less than a specified value.
func NewOpLessOperation ¶
func NewOpLessOperation(path []string, value float64) *OpLessOperation
NewOpLessOperation creates a new OpLessOperation operation.
func (*OpLessOperation) Code ¶
func (op *OpLessOperation) Code() int
Code returns the operation code.
func (*OpLessOperation) Not ¶
func (op *OpLessOperation) Not() bool
Not returns false since this is not a NOT operation.
func (*OpLessOperation) Op ¶
func (op *OpLessOperation) Op() internal.OpType
Op returns the operation type.
func (*OpLessOperation) Path ¶
func (op *OpLessOperation) Path() []string
func (*OpLessOperation) Test ¶
func (op *OpLessOperation) Test(doc any) (bool, error)
Test evaluates the less predicate condition.
func (*OpLessOperation) ToCompact ¶
func (op *OpLessOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpLessOperation) ToJSON ¶
func (op *OpLessOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpLessOperation) Validate ¶
func (op *OpLessOperation) Validate() error
Validate validates the less operation.
type OpMatchesOperation ¶
type OpMatchesOperation struct {
BaseOp
Pattern string // The regex pattern string
IgnoreCase bool // Case insensitive flag
// contains filtered or unexported fields
}
OpMatchesOperation represents a "matches" predicate operation that checks if a string matches a regex pattern.
func NewOpMatchesOperation ¶
func NewOpMatchesOperation(path []string, pattern string, ignoreCase bool) (*OpMatchesOperation, error)
NewOpMatchesOperation creates a new matches operation.
func (*OpMatchesOperation) Code ¶
func (o *OpMatchesOperation) Code() int
Code returns the operation code.
func (*OpMatchesOperation) Op ¶
func (o *OpMatchesOperation) Op() internal.OpType
Op returns the operation type.
func (*OpMatchesOperation) Path ¶
func (o *OpMatchesOperation) Path() []string
func (*OpMatchesOperation) Test ¶
func (o *OpMatchesOperation) Test(doc interface{}) (bool, error)
Test evaluates the matches predicate condition.
func (*OpMatchesOperation) ToCompact ¶
func (o *OpMatchesOperation) ToCompact() (internal.CompactOperation, error)
ToCompact converts the operation to compact array representation.
func (*OpMatchesOperation) ToJSON ¶
func (o *OpMatchesOperation) ToJSON() (internal.Operation, error)
ToJSON converts the operation to JSON representation.
func (*OpMatchesOperation) Validate ¶
func (o *OpMatchesOperation) Validate() error
Validate validates the matches operation.
type OpMergeOperation ¶
type OpMergeOperation struct {
BaseOp
Pos int `json:"pos"` // Merge position
Props map[string]interface{} `json:"props"` // Properties to apply after merge
}
OpMergeOperation represents an array merge operation. path: target path pos: merge position (array index) props: properties to apply after merge (can be nil) Only supports array type fields.
func NewOpMergeOperation ¶
func NewOpMergeOperation(path []string, pos int, props map[string]interface{}) *OpMergeOperation
NewOpMergeOperation creates a new array merge operation.
func (*OpMergeOperation) Code ¶
func (op *OpMergeOperation) Code() int
Code returns the operation code.
func (*OpMergeOperation) Op ¶
func (op *OpMergeOperation) Op() internal.OpType
Op returns the operation type.
func (*OpMergeOperation) Path ¶
func (op *OpMergeOperation) Path() []string
Path returns the operation path.
func (*OpMergeOperation) ToCompact ¶
func (op *OpMergeOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpMergeOperation) ToJSON ¶
func (op *OpMergeOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpMergeOperation) Validate ¶
func (op *OpMergeOperation) Validate() error
Validate validates the merge operation.
type OpMoreOperation ¶
type OpMoreOperation struct {
PredicateOpBase
Value float64 // The number to compare against
}
OpMoreOperation represents a "more" predicate operation that checks if a value is greater than a specified number.
func NewOpMoreOperation ¶
func NewOpMoreOperation(path []string, value float64) *OpMoreOperation
NewOpMoreOperation creates a new more operation.
func (*OpMoreOperation) Code ¶
func (o *OpMoreOperation) Code() int
Code returns the operation code.
func (*OpMoreOperation) Op ¶
func (o *OpMoreOperation) Op() internal.OpType
Op returns the operation type.
func (*OpMoreOperation) Path ¶
func (o *OpMoreOperation) Path() []string
func (*OpMoreOperation) Test ¶
func (o *OpMoreOperation) Test(doc interface{}) (bool, error)
Test evaluates the more predicate condition.
func (*OpMoreOperation) ToCompact ¶
func (o *OpMoreOperation) ToCompact() (internal.CompactOperation, error)
ToCompact converts the operation to compact array representation.
func (*OpMoreOperation) ToJSON ¶
func (o *OpMoreOperation) ToJSON() (internal.Operation, error)
ToJSON converts the operation to JSON representation.
func (*OpMoreOperation) Validate ¶
func (o *OpMoreOperation) Validate() error
Validate validates the more operation.
type OpMoveOperation ¶
OpMoveOperation represents a move operation that moves a value from one path to another.
func NewOpMoveOperation ¶
func NewOpMoveOperation(path, from []string) *OpMoveOperation
NewOpMoveOperation creates a new OpMoveOperation operation.
func (*OpMoveOperation) Code ¶
func (o *OpMoveOperation) Code() int
Code returns the operation code.
func (*OpMoveOperation) From ¶
func (o *OpMoveOperation) From() []string
From returns the source path.
func (*OpMoveOperation) Op ¶
func (o *OpMoveOperation) Op() internal.OpType
Op returns the operation type.
func (*OpMoveOperation) ToCompact ¶
func (o *OpMoveOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpMoveOperation) ToJSON ¶
func (o *OpMoveOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpMoveOperation) Validate ¶
func (o *OpMoveOperation) Validate() error
Validate validates the move operation.
type OpNotOperation ¶
type OpNotOperation struct {
BaseOp
Operations []interface{} `json:"ops"` // Array of operations to negate
}
OpNotOperation represents a logical NOT operation that negates predicates.
func NewOpNotOperation ¶
func NewOpNotOperation(operand internal.PredicateOp) *OpNotOperation
NewOpNotOperation creates a new NOT operation.
func NewOpNotOperationMultiple ¶
func NewOpNotOperationMultiple(path []string, ops []interface{}) *OpNotOperation
NewOpNotOperationMultiple creates a new NOT operation with multiple operands.
func (*OpNotOperation) Not ¶
func (o *OpNotOperation) Not() bool
Not returns true since this is a NOT operation.
func (*OpNotOperation) Op ¶
func (o *OpNotOperation) Op() internal.OpType
Op returns the operation type.
func (*OpNotOperation) Ops ¶
func (o *OpNotOperation) Ops() []internal.PredicateOp
Ops returns the operand operations.
func (*OpNotOperation) Path ¶
func (o *OpNotOperation) Path() []string
Path returns the operation path.
func (*OpNotOperation) Test ¶
func (o *OpNotOperation) Test(doc any) (bool, error)
Test evaluates the NOT predicate condition.
func (*OpNotOperation) ToCompact ¶
func (o *OpNotOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpNotOperation) ToJSON ¶
func (o *OpNotOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpNotOperation) Validate ¶
func (o *OpNotOperation) Validate() error
Validate validates the NOT operation.
type OpOrOperation ¶
type OpOrOperation struct {
BaseOp
Operations []interface{} `json:"ops"` // Array of operations
}
OpOrOperation represents an OR operation that combines multiple predicate operations.
func NewOpOrOperation ¶
func NewOpOrOperation(path []string, ops []interface{}) *OpOrOperation
NewOpOrOperation creates a new OpOrOperation operation.
func (*OpOrOperation) Not ¶
func (o *OpOrOperation) Not() bool
Not returns false since this is not a NOT operation.
func (*OpOrOperation) Op ¶
func (o *OpOrOperation) Op() internal.OpType
Op returns the operation type.
func (*OpOrOperation) Ops ¶
func (o *OpOrOperation) Ops() []internal.PredicateOp
Ops returns the predicate operations.
func (*OpOrOperation) Path ¶
func (o *OpOrOperation) Path() []string
func (*OpOrOperation) Test ¶
func (o *OpOrOperation) Test(doc interface{}) (bool, error)
Test performs the OR operation.
func (*OpOrOperation) ToCompact ¶
func (o *OpOrOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpOrOperation) ToJSON ¶
func (o *OpOrOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpOrOperation) Validate ¶
func (o *OpOrOperation) Validate() error
Validate validates the OR operation.
type OpRemoveOperation ¶
type OpRemoveOperation struct {
BaseOp
OldValue interface{} `json:"oldValue,omitempty"` // The value that was removed (optional)
HasOldValue bool // Whether oldValue is explicitly set
}
OpRemoveOperation represents a remove operation that removes a value at a specified path.
func NewOpRemoveOperation ¶
func NewOpRemoveOperation(path []string) *OpRemoveOperation
NewOpRemoveOperation creates a new OpRemoveOperation operation.
func NewOpRemoveOperationWithOldValue ¶
func NewOpRemoveOperationWithOldValue(path []string, oldValue interface{}) *OpRemoveOperation
NewOpRemoveOperationWithOldValue creates a new OpRemoveOperation operation with oldValue.
func (*OpRemoveOperation) Code ¶
func (o *OpRemoveOperation) Code() int
Code returns the operation code.
func (*OpRemoveOperation) Op ¶
func (o *OpRemoveOperation) Op() internal.OpType
Op returns the operation type.
func (*OpRemoveOperation) Path ¶
func (o *OpRemoveOperation) Path() []string
Path returns the operation path.
func (*OpRemoveOperation) ToCompact ¶
func (o *OpRemoveOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpRemoveOperation) ToJSON ¶
func (o *OpRemoveOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpRemoveOperation) Validate ¶
func (o *OpRemoveOperation) Validate() error
Validate validates the remove operation.
type OpReplaceOperation ¶
type OpReplaceOperation struct {
BaseOp
Value interface{} `json:"value"` // New value
OldValue interface{} `json:"oldValue,omitempty"` // The value that was replaced (optional)
}
OpReplaceOperation represents a replace operation that replaces a value at a specified path.
func NewOpReplaceOperation ¶
func NewOpReplaceOperation(path []string, value interface{}) *OpReplaceOperation
NewOpReplaceOperation creates a new OpReplaceOperation operation.
func NewOpReplaceOperationWithOldValue ¶
func NewOpReplaceOperationWithOldValue(path []string, value interface{}, oldValue interface{}) *OpReplaceOperation
NewOpReplaceOperationWithOldValue creates a new OpReplaceOperation operation with oldValue.
func (*OpReplaceOperation) Code ¶
func (o *OpReplaceOperation) Code() int
Code returns the operation code.
func (*OpReplaceOperation) Op ¶
func (o *OpReplaceOperation) Op() internal.OpType
Op returns the operation type.
func (*OpReplaceOperation) Path ¶
func (o *OpReplaceOperation) Path() []string
Path returns the operation path.
func (*OpReplaceOperation) ToCompact ¶
func (o *OpReplaceOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpReplaceOperation) ToJSON ¶
func (o *OpReplaceOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpReplaceOperation) Validate ¶
func (o *OpReplaceOperation) Validate() error
Validate validates the replace operation.
type OpSplitOperation ¶
type OpSplitOperation struct {
BaseOp
Pos int `json:"pos"` // Split position
Props interface{} `json:"props"` // Properties to apply after split
}
OpSplitOperation represents a string split operation. path: target path pos: split position (rune index) props: properties to apply after split (can be nil) Only supports string type fields.
func NewOpSplitOperation ¶
func NewOpSplitOperation(path []string, pos int, props interface{}) *OpSplitOperation
NewOpSplitOperation creates a new string split operation.
func (*OpSplitOperation) Code ¶
func (op *OpSplitOperation) Code() int
Code returns the operation code.
func (*OpSplitOperation) Op ¶
func (op *OpSplitOperation) Op() internal.OpType
Op returns the operation type.
func (*OpSplitOperation) Path ¶
func (op *OpSplitOperation) Path() []string
Path returns the operation path.
func (*OpSplitOperation) ToCompact ¶
func (op *OpSplitOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpSplitOperation) ToJSON ¶
func (op *OpSplitOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpSplitOperation) Validate ¶
func (op *OpSplitOperation) Validate() error
Validate validates the split operation.
type OpStartsOperation ¶
type OpStartsOperation struct {
BaseOp
Value string `json:"value"` // Expected prefix
IgnoreCase bool `json:"ignore_case"` // Whether to ignore case
}
OpStartsOperation represents a test operation that checks if a string value starts with a specific prefix.
func NewOpStartsOperation ¶
func NewOpStartsOperation(path []string, prefix string) *OpStartsOperation
NewOpStartsOperation creates a new OpStartsOperation operation.
func NewOpStartsOperationWithIgnoreCase ¶
func NewOpStartsOperationWithIgnoreCase(path []string, prefix string, ignoreCase bool) *OpStartsOperation
NewOpStartsOperationWithIgnoreCase creates a new OpStartsOperation operation with ignore case option.
func (*OpStartsOperation) Code ¶
func (op *OpStartsOperation) Code() int
Code returns the operation code.
func (*OpStartsOperation) Op ¶
func (op *OpStartsOperation) Op() internal.OpType
Op returns the operation type.
func (*OpStartsOperation) Path ¶
func (op *OpStartsOperation) Path() []string
Path returns the operation path.
func (*OpStartsOperation) Test ¶
func (op *OpStartsOperation) Test(doc any) (bool, error)
Test evaluates the starts predicate condition.
func (*OpStartsOperation) ToCompact ¶
func (op *OpStartsOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpStartsOperation) ToJSON ¶
func (op *OpStartsOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpStartsOperation) Validate ¶
func (op *OpStartsOperation) Validate() error
Validate validates the starts operation.
type OpStrDelOperation ¶
type OpStrDelOperation struct {
BaseOp
Pos int `json:"pos"` // Delete position
Len int `json:"len"` // Number of characters to delete
Str string `json:"str"` // Specific string to delete (optional)
}
OpStrDelOperation represents a string delete operation. path: target path pos: start position (rune index) len: number of runes to delete (when Str is empty) str: specific string to delete (when not empty, takes precedence) Only supports string type fields.
func NewOpStrDelOperation ¶
func NewOpStrDelOperation(path []string, pos, length int) *OpStrDelOperation
NewOpStrDelOperation creates a new string delete operation with length.
func NewOpStrDelOperationWithStr ¶
func NewOpStrDelOperationWithStr(path []string, pos int, str string) *OpStrDelOperation
NewOpStrDelOperationWithStr creates a new string delete operation with specific string.
func (*OpStrDelOperation) Code ¶
func (op *OpStrDelOperation) Code() int
Code returns the operation code.
func (*OpStrDelOperation) Op ¶
func (op *OpStrDelOperation) Op() internal.OpType
Op returns the operation type.
func (*OpStrDelOperation) ToCompact ¶
func (o *OpStrDelOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpStrDelOperation) ToJSON ¶
func (o *OpStrDelOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpStrDelOperation) Validate ¶
func (op *OpStrDelOperation) Validate() error
Validate validates the string delete operation.
type OpStrInsOperation ¶
type OpStrInsOperation struct {
BaseOp
Pos int `json:"pos"` // Insert position
Str string `json:"str"` // String to insert
}
OpStrInsOperation represents a string insert operation. path: target path pos: insert position (rune index) str: string to insert Only supports string type fields.
func NewOpStrInsOperation ¶
func NewOpStrInsOperation(path []string, pos int, str string) *OpStrInsOperation
NewOpStrInsOperation creates a new string insert operation.
func (*OpStrInsOperation) Code ¶
func (op *OpStrInsOperation) Code() int
Code returns the operation code.
func (*OpStrInsOperation) Op ¶
func (op *OpStrInsOperation) Op() internal.OpType
Op returns the operation type.
func (*OpStrInsOperation) ToCompact ¶
func (op *OpStrInsOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpStrInsOperation) ToJSON ¶
func (op *OpStrInsOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpStrInsOperation) Validate ¶
func (op *OpStrInsOperation) Validate() error
Validate validates the string insert operation.
type OpTestOperation ¶
type OpTestOperation struct {
BaseOp
Value interface{} `json:"value"` // Expected value
NotFlag bool `json:"not,omitempty"` // Whether to negate the test
}
OpTestOperation represents a test operation that checks if a value equals a specified value.
func NewOpTestOperation ¶
func NewOpTestOperation(path []string, value interface{}) *OpTestOperation
NewOpTestOperation creates a new OpTestOperation operation.
func (*OpTestOperation) Code ¶
func (o *OpTestOperation) Code() int
Code returns the operation code.
func (*OpTestOperation) Not ¶
func (o *OpTestOperation) Not() bool
Not returns whether this operation is negated.
func (*OpTestOperation) Op ¶
func (o *OpTestOperation) Op() internal.OpType
Op returns the operation type.
func (*OpTestOperation) Path ¶
func (o *OpTestOperation) Path() []string
Path returns the operation path.
func (*OpTestOperation) Test ¶
func (o *OpTestOperation) Test(doc interface{}) (bool, error)
Test performs the test operation.
func (*OpTestOperation) ToCompact ¶
func (o *OpTestOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpTestOperation) ToJSON ¶
func (o *OpTestOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpTestOperation) Validate ¶
func (o *OpTestOperation) Validate() error
Validate validates the test operation.
type OpTestStringLenOperation ¶
type OpTestStringLenOperation struct {
BaseOp
Length int `json:"length"` // Expected string length
Not bool `json:"not"` // Whether to negate the result
}
OpTestStringLenOperation represents a test operation that checks if a string value has a specific length.
func NewOpTestStringLenOperation ¶
func NewOpTestStringLenOperation(path []string, expectedLength int) *OpTestStringLenOperation
NewOpTestStringLenOperation creates a new OpTestStringLenOperation operation.
func NewOpTestStringLenOperationWithNot ¶
func NewOpTestStringLenOperationWithNot(path []string, expectedLength int, not bool) *OpTestStringLenOperation
NewOpTestStringLenOperationWithNot creates a new OpTestStringLenOperation operation with not flag.
func (*OpTestStringLenOperation) Apply ¶
Apply applies the test string length operation to the document.
func (*OpTestStringLenOperation) Code ¶
func (op *OpTestStringLenOperation) Code() int
Code returns the operation code.
func (*OpTestStringLenOperation) Op ¶
func (op *OpTestStringLenOperation) Op() internal.OpType
Op returns the operation type.
func (*OpTestStringLenOperation) Path ¶
func (op *OpTestStringLenOperation) Path() []string
Path returns the operation path.
func (*OpTestStringLenOperation) ToCompact ¶
func (op *OpTestStringLenOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpTestStringLenOperation) ToJSON ¶
func (op *OpTestStringLenOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpTestStringLenOperation) Validate ¶
func (op *OpTestStringLenOperation) Validate() error
Validate validates the test string length operation.
type OpTestStringOperation ¶
type OpTestStringOperation struct {
BaseOp
Str string `json:"str"` // Expected string value
Pos int `json:"pos"` // Position within string (optional)
}
OpTestStringOperation represents a test operation that checks if a value is a string and matches a pattern.
func NewOpTestStringOperation ¶
func NewOpTestStringOperation(path []string, expectedValue string) *OpTestStringOperation
NewOpTestStringOperation creates a new OpTestStringOperation operation.
func NewOpTestStringOperationWithPos ¶
func NewOpTestStringOperationWithPos(path []string, expectedValue string, pos int) *OpTestStringOperation
NewOpTestStringOperationWithPos creates a new OpTestStringOperation operation with position.
func (*OpTestStringOperation) Code ¶
func (op *OpTestStringOperation) Code() int
Code returns the operation code.
func (*OpTestStringOperation) Op ¶
func (op *OpTestStringOperation) Op() internal.OpType
Op returns the operation type.
func (*OpTestStringOperation) Path ¶
func (op *OpTestStringOperation) Path() []string
Path returns the operation path.
func (*OpTestStringOperation) Test ¶
func (op *OpTestStringOperation) Test(doc any) (bool, error)
Test evaluates the test string predicate condition.
func (*OpTestStringOperation) ToCompact ¶
func (op *OpTestStringOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpTestStringOperation) ToJSON ¶
func (op *OpTestStringOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpTestStringOperation) Validate ¶
func (op *OpTestStringOperation) Validate() error
Validate validates the test string operation.
type OpTestTypeOperation ¶
OpTestTypeOperation represents a test operation that checks if a value is of a specific type.
func NewOpTestTypeOperation ¶
func NewOpTestTypeOperation(path []string, expectedType string) *OpTestTypeOperation
NewOpTestTypeOperation creates a new OpTestTypeOperation operation.
func NewOpTestTypeOperationMultiple ¶
func NewOpTestTypeOperationMultiple(path []string, expectedTypes []string) *OpTestTypeOperation
NewOpTestTypeOperationMultiple creates a new OpTestTypeOperation operation with multiple internal.
func (*OpTestTypeOperation) Code ¶
func (op *OpTestTypeOperation) Code() int
Code returns the operation code.
func (*OpTestTypeOperation) Not ¶
func (op *OpTestTypeOperation) Not() bool
Not returns false (test_type operation doesn't support not modifier).
func (*OpTestTypeOperation) Op ¶
func (op *OpTestTypeOperation) Op() internal.OpType
Op returns the operation type.
func (*OpTestTypeOperation) Path ¶
func (op *OpTestTypeOperation) Path() []string
Path returns the operation path.
func (*OpTestTypeOperation) Test ¶
func (op *OpTestTypeOperation) Test(doc any) (bool, error)
Test evaluates the test type predicate condition.
func (*OpTestTypeOperation) ToCompact ¶
func (op *OpTestTypeOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpTestTypeOperation) ToJSON ¶
func (op *OpTestTypeOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpTestTypeOperation) Validate ¶
func (op *OpTestTypeOperation) Validate() error
Validate validates the test type operation.
type OpTypeOperation ¶
OpTypeOperation represents a type operation that checks if a value is of a specific type.
func NewOpTypeOperation ¶
func NewOpTypeOperation(path []string, expectedType string) *OpTypeOperation
NewOpTypeOperation creates a new OpTypeOperation operation.
func (*OpTypeOperation) Code ¶
func (op *OpTypeOperation) Code() int
Code returns the operation code.
func (*OpTypeOperation) Not ¶
func (op *OpTypeOperation) Not() bool
Not returns false (type operation doesn't support not modifier).
func (*OpTypeOperation) Op ¶
func (op *OpTypeOperation) Op() internal.OpType
Op returns the operation type.
func (*OpTypeOperation) Path ¶
func (op *OpTypeOperation) Path() []string
Path returns the operation path.
func (*OpTypeOperation) Test ¶
func (op *OpTypeOperation) Test(doc any) (bool, error)
Test evaluates the type predicate condition.
func (*OpTypeOperation) ToCompact ¶
func (op *OpTypeOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpTypeOperation) ToJSON ¶
func (op *OpTypeOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpTypeOperation) Validate ¶
func (op *OpTypeOperation) Validate() error
Validate validates the type operation.
type OpUndefinedOperation ¶
type OpUndefinedOperation struct {
PredicateOpBase
}
OpUndefinedOperation represents an undefined operation that checks if a path doesn't exist.
func NewOpUndefinedOperation ¶
func NewOpUndefinedOperation(path []string, not bool) *OpUndefinedOperation
NewOpUndefinedOperation creates a new undefined operation.
func (*OpUndefinedOperation) Code ¶
func (o *OpUndefinedOperation) Code() int
Code returns the operation code.
func (*OpUndefinedOperation) Not ¶
func (o *OpUndefinedOperation) Not() bool
Not returns false (undefined operation doesn't support not modifier).
func (*OpUndefinedOperation) Op ¶
func (o *OpUndefinedOperation) Op() internal.OpType
Op returns the operation type.
func (*OpUndefinedOperation) Path ¶
func (o *OpUndefinedOperation) Path() []string
func (*OpUndefinedOperation) Test ¶
func (o *OpUndefinedOperation) Test(doc interface{}) (bool, error)
Test performs the undefined operation.
func (*OpUndefinedOperation) ToCompact ¶
func (o *OpUndefinedOperation) ToCompact() (internal.CompactOperation, error)
ToCompact serializes the operation to compact format.
func (*OpUndefinedOperation) ToJSON ¶
func (o *OpUndefinedOperation) ToJSON() (internal.Operation, error)
ToJSON serializes the operation to JSON format.
func (*OpUndefinedOperation) Validate ¶
func (o *OpUndefinedOperation) Validate() error
Validate validates the undefined operation.
type PredicateOp ¶
type PredicateOp = internal.PredicateOp
PredicateOp represents predicate operations used for testing conditions.
type PredicateOpBase ¶
type PredicateOpBase struct {
BaseOp
// contains filtered or unexported fields
}
PredicateOpBase provides common functionality for predicate operations.
func NewPredicateOp ¶
func NewPredicateOp(path []string, not bool) PredicateOpBase
NewPredicateOp creates a new PredicateOpBase.
type SecondOrderPredicateOp ¶
type SecondOrderPredicateOp = internal.SecondOrderPredicateOp
SecondOrderPredicateOp represents operations that combine multiple predicate operations.