package querycodec

import "fmt"

// ValidationError is safe to project as a malformed CRM query. It preserves
// the existing public error text without importing the legacy shared module.
type ValidationError struct {
	Field   string
	Message string
}

func (e *ValidationError) Error() string {
	if e.Field != "" {
		return fmt.Sprintf("validation error on field '%s': %s", e.Field, e.Message)
	}
	return fmt.Sprintf("validation error: %s", e.Message)
}

func newValidationError(subject, message string) error {
	return &ValidationError{Field: subject, Message: message}
}
