diff --git a/pkg/errors/dict_test.go b/pkg/errors/dict_test.go index 849fedf..3f7190c 100644 --- a/pkg/errors/dict_test.go +++ b/pkg/errors/dict_test.go @@ -151,9 +151,9 @@ func TestErrorConfigFluentMethods(t *testing.T) { // Start with nil and chain fluent methods config := (*errors.ErrorConfig)(nil). - WithMessage("short", "long"). - WithDocs("https://docs.example.com"). - WithTrace("https://trace.example.com"). + WithErrorMessage("short", "long"). + WithDocsURI("https://docs.example.com"). + WithTraceURI("https://trace.example.com"). WithCode(code). WithMeta("key1", "value1"). WithMeta("key2", "value2") @@ -190,7 +190,7 @@ func TestErrorConfigFluentMethodsChaining(t *testing.T) { } // Child overrides some values - merged := parent.WithMessage("child short", "").WithDocs("https://child.com/docs") + merged := parent.WithErrorMessage("child short", "").WithDocsURI("https://child.com/docs") // Child takes precedence for Short if merged.Short != "child short" { @@ -219,14 +219,14 @@ func TestErrorConfigFluentMethodsNilReceiver(t *testing.T) { var config *errors.ErrorConfig // All methods should work on nil receiver - if result := config.WithMessage("short", "long"); result.Short != "short" { - t.Error("WithMessage should work on nil receiver") + if result := config.WithErrorMessage("short", "long"); result.Short != "short" { + t.Error("WithErrorMessage should work on nil receiver") } - if result := config.WithDocs("docs"); result.DocsURI != "docs" { - t.Error("WithDocs should work on nil receiver") + if result := config.WithDocsURI("docs"); result.DocsURI != "docs" { + t.Error("WithDocsURI should work on nil receiver") } - if result := config.WithTrace("trace"); result.TraceURI != "trace" { - t.Error("WithTrace should work on nil receiver") + if result := config.WithTraceURI("trace"); result.TraceURI != "trace" { + t.Error("WithTraceURI should work on nil receiver") } code := errors.ErrorCode("CODE") if result := config.WithCode(code); result.Code == nil || *result.Code != code { diff --git a/pkg/errors/error_config.go b/pkg/errors/error_config.go index 4a3b2c9..68928c5 100644 --- a/pkg/errors/error_config.go +++ b/pkg/errors/error_config.go @@ -53,21 +53,21 @@ type ErrorConfigurable[T any, Self any] interface { WithErrorCallback(fn ErrorCallback) Self } -// WithMessage returns a new ErrorConfig with the given short and long messages merged. +// WithErrorMessage returns a new ErrorConfig with the given short and long messages merged. // This method is nil-receiver safe. -func (c *ErrorConfig) WithMessage(short, long string) *ErrorConfig { +func (c *ErrorConfig) WithErrorMessage(short, long string) *ErrorConfig { return mergeErrorConfig(c, &ErrorConfig{Short: short, Long: long}) } -// WithDocs returns a new ErrorConfig with the given documentation URI merged. +// WithDocsURI returns a new ErrorConfig with the given documentation URI merged. // This method is nil-receiver safe. -func (c *ErrorConfig) WithDocs(uri string) *ErrorConfig { +func (c *ErrorConfig) WithDocsURI(uri string) *ErrorConfig { return mergeErrorConfig(c, &ErrorConfig{DocsURI: uri}) } -// WithTrace returns a new ErrorConfig with the given trace URI merged. +// WithTraceURI returns a new ErrorConfig with the given trace URI merged. // This method is nil-receiver safe. -func (c *ErrorConfig) WithTrace(uri string) *ErrorConfig { +func (c *ErrorConfig) WithTraceURI(uri string) *ErrorConfig { return mergeErrorConfig(c, &ErrorConfig{TraceURI: uri}) } diff --git a/pkg/rules/any.go b/pkg/rules/any.go index bd866ad..bfa9796 100644 --- a/pkg/rules/any.go +++ b/pkg/rules/any.go @@ -199,17 +199,17 @@ func (ruleSet *AnyRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *AnyRuleSet) WithErrorMessage(short, long string) *AnyRuleSet { - return v.clone(anyWithLabel(util.FormatErrorMessageLabel(short, long)), anyWithErrorConfig(v.errorConfig.WithMessage(short, long))) + return v.clone(anyWithLabel(util.FormatErrorMessageLabel(short, long)), anyWithErrorConfig(v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *AnyRuleSet) WithDocsURI(uri string) *AnyRuleSet { - return v.clone(anyWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), anyWithErrorConfig(v.errorConfig.WithDocs(uri))) + return v.clone(anyWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), anyWithErrorConfig(v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *AnyRuleSet) WithTraceURI(uri string) *AnyRuleSet { - return v.clone(anyWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), anyWithErrorConfig(v.errorConfig.WithTrace(uri))) + return v.clone(anyWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), anyWithErrorConfig(v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/bool.go b/pkg/rules/bool.go index f07e4f1..6607768 100644 --- a/pkg/rules/bool.go +++ b/pkg/rules/bool.go @@ -306,17 +306,17 @@ func (ruleSet *BoolRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *BoolRuleSet) WithErrorMessage(short, long string) *BoolRuleSet { - return v.clone(boolWithLabel("WithErrorMessage(...)"), boolWithErrorConfig(v.errorConfig.WithMessage(short, long))) + return v.clone(boolWithLabel("WithErrorMessage(...)"), boolWithErrorConfig(v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *BoolRuleSet) WithDocsURI(uri string) *BoolRuleSet { - return v.clone(boolWithLabel("WithDocsURI(...)"), boolWithErrorConfig(v.errorConfig.WithDocs(uri))) + return v.clone(boolWithLabel("WithDocsURI(...)"), boolWithErrorConfig(v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *BoolRuleSet) WithTraceURI(uri string) *BoolRuleSet { - return v.clone(boolWithLabel("WithTraceURI(...)"), boolWithErrorConfig(v.errorConfig.WithTrace(uri))) + return v.clone(boolWithLabel("WithTraceURI(...)"), boolWithErrorConfig(v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/constant.go b/pkg/rules/constant.go index 99892f9..d1c0dfd 100644 --- a/pkg/rules/constant.go +++ b/pkg/rules/constant.go @@ -166,17 +166,17 @@ func (ruleSet *ConstantRuleSet[T]) Value() T { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *ConstantRuleSet[T]) WithErrorMessage(short, long string) *ConstantRuleSet[T] { - return ruleSet.clone(constantWithErrorConfig[T](ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(constantWithErrorConfig[T](ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *ConstantRuleSet[T]) WithDocsURI(uri string) *ConstantRuleSet[T] { - return ruleSet.clone(constantWithErrorConfig[T](ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(constantWithErrorConfig[T](ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *ConstantRuleSet[T]) WithTraceURI(uri string) *ConstantRuleSet[T] { - return ruleSet.clone(constantWithErrorConfig[T](ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(constantWithErrorConfig[T](ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/float.go b/pkg/rules/float.go index 854d113..f1a3a2d 100644 --- a/pkg/rules/float.go +++ b/pkg/rules/float.go @@ -350,17 +350,17 @@ func (ruleSet *FloatRuleSet[T]) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *FloatRuleSet[T]) WithErrorMessage(short, long string) *FloatRuleSet[T] { - return v.clone(floatWithLabel[T](util.FormatErrorMessageLabel(short, long)), floatWithErrorConfig[T](v.errorConfig.WithMessage(short, long))) + return v.clone(floatWithLabel[T](util.FormatErrorMessageLabel(short, long)), floatWithErrorConfig[T](v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *FloatRuleSet[T]) WithDocsURI(uri string) *FloatRuleSet[T] { - return v.clone(floatWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), floatWithErrorConfig[T](v.errorConfig.WithDocs(uri))) + return v.clone(floatWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), floatWithErrorConfig[T](v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *FloatRuleSet[T]) WithTraceURI(uri string) *FloatRuleSet[T] { - return v.clone(floatWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), floatWithErrorConfig[T](v.errorConfig.WithTrace(uri))) + return v.clone(floatWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), floatWithErrorConfig[T](v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/inerface.go b/pkg/rules/inerface.go index c968226..7eca9de 100644 --- a/pkg/rules/inerface.go +++ b/pkg/rules/inerface.go @@ -218,17 +218,17 @@ func (ruleSet *InterfaceRuleSet[T]) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *InterfaceRuleSet[T]) WithErrorMessage(short, long string) *InterfaceRuleSet[T] { - return v.clone(interfaceWithLabel[T](util.FormatErrorMessageLabel(short, long)), interfaceWithErrorConfig[T](v.errorConfig.WithMessage(short, long))) + return v.clone(interfaceWithLabel[T](util.FormatErrorMessageLabel(short, long)), interfaceWithErrorConfig[T](v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *InterfaceRuleSet[T]) WithDocsURI(uri string) *InterfaceRuleSet[T] { - return v.clone(interfaceWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), interfaceWithErrorConfig[T](v.errorConfig.WithDocs(uri))) + return v.clone(interfaceWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), interfaceWithErrorConfig[T](v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *InterfaceRuleSet[T]) WithTraceURI(uri string) *InterfaceRuleSet[T] { - return v.clone(interfaceWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), interfaceWithErrorConfig[T](v.errorConfig.WithTrace(uri))) + return v.clone(interfaceWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), interfaceWithErrorConfig[T](v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/int.go b/pkg/rules/int.go index 43987cd..1466317 100644 --- a/pkg/rules/int.go +++ b/pkg/rules/int.go @@ -434,17 +434,17 @@ func (ruleSet *IntRuleSet[T]) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *IntRuleSet[T]) WithErrorMessage(short, long string) *IntRuleSet[T] { - return v.clone(intWithLabel[T](util.FormatErrorMessageLabel(short, long)), intWithErrorConfig[T](v.errorConfig.WithMessage(short, long))) + return v.clone(intWithLabel[T](util.FormatErrorMessageLabel(short, long)), intWithErrorConfig[T](v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *IntRuleSet[T]) WithDocsURI(uri string) *IntRuleSet[T] { - return v.clone(intWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), intWithErrorConfig[T](v.errorConfig.WithDocs(uri))) + return v.clone(intWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), intWithErrorConfig[T](v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *IntRuleSet[T]) WithTraceURI(uri string) *IntRuleSet[T] { - return v.clone(intWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), intWithErrorConfig[T](v.errorConfig.WithTrace(uri))) + return v.clone(intWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), intWithErrorConfig[T](v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/net/domain.go b/pkg/rules/net/domain.go index 4a93069..3904a29 100644 --- a/pkg/rules/net/domain.go +++ b/pkg/rules/net/domain.go @@ -312,17 +312,17 @@ func (ruleSet *DomainRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *DomainRuleSet) WithErrorMessage(short, long string) *DomainRuleSet { - return ruleSet.clone(domainWithLabel(util.FormatErrorMessageLabel(short, long)), domainWithErrorConfig(ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(domainWithLabel(util.FormatErrorMessageLabel(short, long)), domainWithErrorConfig(ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *DomainRuleSet) WithDocsURI(uri string) *DomainRuleSet { - return ruleSet.clone(domainWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), domainWithErrorConfig(ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(domainWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), domainWithErrorConfig(ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *DomainRuleSet) WithTraceURI(uri string) *DomainRuleSet { - return ruleSet.clone(domainWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), domainWithErrorConfig(ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(domainWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), domainWithErrorConfig(ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/net/email.go b/pkg/rules/net/email.go index 838e1b0..1c60d61 100644 --- a/pkg/rules/net/email.go +++ b/pkg/rules/net/email.go @@ -341,17 +341,17 @@ func (ruleSet *EmailRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *EmailRuleSet) WithErrorMessage(short, long string) *EmailRuleSet { - return ruleSet.clone(emailWithLabel(util.FormatErrorMessageLabel(short, long)), emailWithErrorConfig(ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(emailWithLabel(util.FormatErrorMessageLabel(short, long)), emailWithErrorConfig(ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *EmailRuleSet) WithDocsURI(uri string) *EmailRuleSet { - return ruleSet.clone(emailWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), emailWithErrorConfig(ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(emailWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), emailWithErrorConfig(ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *EmailRuleSet) WithTraceURI(uri string) *EmailRuleSet { - return ruleSet.clone(emailWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), emailWithErrorConfig(ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(emailWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), emailWithErrorConfig(ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/net/ip.go b/pkg/rules/net/ip.go index 35042ba..e517592 100644 --- a/pkg/rules/net/ip.go +++ b/pkg/rules/net/ip.go @@ -334,17 +334,17 @@ func (ruleSet *IPRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *IPRuleSet) WithErrorMessage(short, long string) *IPRuleSet { - return ruleSet.clone(ipWithLabel(util.FormatErrorMessageLabel(short, long)), ipWithErrorConfig(ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(ipWithLabel(util.FormatErrorMessageLabel(short, long)), ipWithErrorConfig(ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *IPRuleSet) WithDocsURI(uri string) *IPRuleSet { - return ruleSet.clone(ipWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), ipWithErrorConfig(ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(ipWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), ipWithErrorConfig(ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *IPRuleSet) WithTraceURI(uri string) *IPRuleSet { - return ruleSet.clone(ipWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), ipWithErrorConfig(ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(ipWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), ipWithErrorConfig(ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/net/uri.go b/pkg/rules/net/uri.go index f79e2ca..4c78819 100644 --- a/pkg/rules/net/uri.go +++ b/pkg/rules/net/uri.go @@ -808,17 +808,17 @@ func uriWithConflictType(ct uriConflictType) uriCloneOption { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *URIRuleSet) WithErrorMessage(short, long string) *URIRuleSet { - return ruleSet.clone(uriWithLabel(util.FormatErrorMessageLabel(short, long)), uriWithErrorConfig(ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(uriWithLabel(util.FormatErrorMessageLabel(short, long)), uriWithErrorConfig(ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *URIRuleSet) WithDocsURI(uri string) *URIRuleSet { - return ruleSet.clone(uriWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), uriWithErrorConfig(ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(uriWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), uriWithErrorConfig(ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *URIRuleSet) WithTraceURI(uri string) *URIRuleSet { - return ruleSet.clone(uriWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), uriWithErrorConfig(ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(uriWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), uriWithErrorConfig(ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/object.go b/pkg/rules/object.go index 38ed3b9..3c2a23d 100644 --- a/pkg/rules/object.go +++ b/pkg/rules/object.go @@ -951,17 +951,17 @@ func (ruleSet *ObjectRuleSet[T, TK, TV]) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *ObjectRuleSet[T, TK, TV]) WithErrorMessage(short, long string) *ObjectRuleSet[T, TK, TV] { - return v.clone(objectWithLabel[T, TK, TV](util.FormatErrorMessageLabel(short, long)), objectWithErrorConfig[T, TK, TV](v.errorConfig.WithMessage(short, long))) + return v.clone(objectWithLabel[T, TK, TV](util.FormatErrorMessageLabel(short, long)), objectWithErrorConfig[T, TK, TV](v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *ObjectRuleSet[T, TK, TV]) WithDocsURI(uri string) *ObjectRuleSet[T, TK, TV] { - return v.clone(objectWithLabel[T, TK, TV](util.FormatStringArgLabel("WithDocsURI", uri)), objectWithErrorConfig[T, TK, TV](v.errorConfig.WithDocs(uri))) + return v.clone(objectWithLabel[T, TK, TV](util.FormatStringArgLabel("WithDocsURI", uri)), objectWithErrorConfig[T, TK, TV](v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *ObjectRuleSet[T, TK, TV]) WithTraceURI(uri string) *ObjectRuleSet[T, TK, TV] { - return v.clone(objectWithLabel[T, TK, TV](util.FormatStringArgLabel("WithTraceURI", uri)), objectWithErrorConfig[T, TK, TV](v.errorConfig.WithTrace(uri))) + return v.clone(objectWithLabel[T, TK, TV](util.FormatStringArgLabel("WithTraceURI", uri)), objectWithErrorConfig[T, TK, TV](v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/slice.go b/pkg/rules/slice.go index 591b551..edf5fbe 100644 --- a/pkg/rules/slice.go +++ b/pkg/rules/slice.go @@ -650,17 +650,17 @@ func (ruleSet *SliceRuleSet[T]) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *SliceRuleSet[T]) WithErrorMessage(short, long string) *SliceRuleSet[T] { - return v.clone(sliceWithLabel[T](util.FormatErrorMessageLabel(short, long)), sliceWithErrorConfig[T](v.errorConfig.WithMessage(short, long))) + return v.clone(sliceWithLabel[T](util.FormatErrorMessageLabel(short, long)), sliceWithErrorConfig[T](v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *SliceRuleSet[T]) WithDocsURI(uri string) *SliceRuleSet[T] { - return v.clone(sliceWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), sliceWithErrorConfig[T](v.errorConfig.WithDocs(uri))) + return v.clone(sliceWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), sliceWithErrorConfig[T](v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *SliceRuleSet[T]) WithTraceURI(uri string) *SliceRuleSet[T] { - return v.clone(sliceWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), sliceWithErrorConfig[T](v.errorConfig.WithTrace(uri))) + return v.clone(sliceWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), sliceWithErrorConfig[T](v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/string.go b/pkg/rules/string.go index 138fb22..482b5e5 100644 --- a/pkg/rules/string.go +++ b/pkg/rules/string.go @@ -278,17 +278,17 @@ func (ruleSet *StringRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *StringRuleSet) WithErrorMessage(short, long string) *StringRuleSet { - return v.clone(stringWithLabel(util.FormatErrorMessageLabel(short, long)), stringWithErrorConfig(v.errorConfig.WithMessage(short, long))) + return v.clone(stringWithLabel(util.FormatErrorMessageLabel(short, long)), stringWithErrorConfig(v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *StringRuleSet) WithDocsURI(uri string) *StringRuleSet { - return v.clone(stringWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), stringWithErrorConfig(v.errorConfig.WithDocs(uri))) + return v.clone(stringWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), stringWithErrorConfig(v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *StringRuleSet) WithTraceURI(uri string) *StringRuleSet { - return v.clone(stringWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), stringWithErrorConfig(v.errorConfig.WithTrace(uri))) + return v.clone(stringWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), stringWithErrorConfig(v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/time/duration.go b/pkg/rules/time/duration.go index 48aa8be..420b25b 100644 --- a/pkg/rules/time/duration.go +++ b/pkg/rules/time/duration.go @@ -453,30 +453,30 @@ func (ruleSet *DurationRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *DurationRuleSet) WithErrorMessage(short, long string) *DurationRuleSet { - return ruleSet.clone(durationWithLabel("WithErrorMessage(...)"), durationWithErrorConfig(ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(durationWithLabel(util.FormatErrorMessageLabel(short, long)), durationWithErrorConfig(ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *DurationRuleSet) WithDocsURI(uri string) *DurationRuleSet { - return ruleSet.clone(durationWithLabel("WithDocsURI(...)"), durationWithErrorConfig(ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(durationWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), durationWithErrorConfig(ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *DurationRuleSet) WithTraceURI(uri string) *DurationRuleSet { - return ruleSet.clone(durationWithLabel("WithTraceURI(...)"), durationWithErrorConfig(ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(durationWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), durationWithErrorConfig(ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. func (ruleSet *DurationRuleSet) WithErrorCode(code errors.ErrorCode) *DurationRuleSet { - return ruleSet.clone(durationWithLabel("WithErrorCode(...)"), durationWithErrorConfig(ruleSet.errorConfig.WithCode(code))) + return ruleSet.clone(durationWithLabel(util.FormatErrorCodeLabel(code)), durationWithErrorConfig(ruleSet.errorConfig.WithCode(code))) } // WithErrorMeta returns a new RuleSet with additional error metadata. func (ruleSet *DurationRuleSet) WithErrorMeta(key string, value any) *DurationRuleSet { - return ruleSet.clone(durationWithLabel("WithErrorMeta(...)"), durationWithErrorConfig(ruleSet.errorConfig.WithMeta(key, value))) + return ruleSet.clone(durationWithLabel(util.FormatErrorMetaLabel(key, value)), durationWithErrorConfig(ruleSet.errorConfig.WithMeta(key, value))) } // WithErrorCallback returns a new RuleSet with an error callback for customization. func (ruleSet *DurationRuleSet) WithErrorCallback(fn errors.ErrorCallback) *DurationRuleSet { - return ruleSet.clone(durationWithLabel("WithErrorCallback(...)"), durationWithErrorConfig(ruleSet.errorConfig.WithCallback(fn))) + return ruleSet.clone(durationWithLabel(util.FormatErrorCallbackLabel()), durationWithErrorConfig(ruleSet.errorConfig.WithCallback(fn))) } diff --git a/pkg/rules/time/time.go b/pkg/rules/time/time.go index 113a7ed..19a1998 100644 --- a/pkg/rules/time/time.go +++ b/pkg/rules/time/time.go @@ -357,17 +357,17 @@ func (ruleSet *TimeRuleSet) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (ruleSet *TimeRuleSet) WithErrorMessage(short, long string) *TimeRuleSet { - return ruleSet.clone(timeWithLabel(util.FormatErrorMessageLabel(short, long)), timeWithErrorConfig(ruleSet.errorConfig.WithMessage(short, long))) + return ruleSet.clone(timeWithLabel(util.FormatErrorMessageLabel(short, long)), timeWithErrorConfig(ruleSet.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (ruleSet *TimeRuleSet) WithDocsURI(uri string) *TimeRuleSet { - return ruleSet.clone(timeWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), timeWithErrorConfig(ruleSet.errorConfig.WithDocs(uri))) + return ruleSet.clone(timeWithLabel(util.FormatStringArgLabel("WithDocsURI", uri)), timeWithErrorConfig(ruleSet.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (ruleSet *TimeRuleSet) WithTraceURI(uri string) *TimeRuleSet { - return ruleSet.clone(timeWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), timeWithErrorConfig(ruleSet.errorConfig.WithTrace(uri))) + return ruleSet.clone(timeWithLabel(util.FormatStringArgLabel("WithTraceURI", uri)), timeWithErrorConfig(ruleSet.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/rules/wrap_any.go b/pkg/rules/wrap_any.go index 762e7a7..485a984 100644 --- a/pkg/rules/wrap_any.go +++ b/pkg/rules/wrap_any.go @@ -200,17 +200,17 @@ func (ruleSet *WrapAnyRuleSet[T]) String() string { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (v *WrapAnyRuleSet[T]) WithErrorMessage(short, long string) *WrapAnyRuleSet[T] { - return v.clone(wrapAnyWithLabel[T](util.FormatErrorMessageLabel(short, long)), wrapAnyWithErrorConfig[T](v.errorConfig.WithMessage(short, long))) + return v.clone(wrapAnyWithLabel[T](util.FormatErrorMessageLabel(short, long)), wrapAnyWithErrorConfig[T](v.errorConfig.WithErrorMessage(short, long))) } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (v *WrapAnyRuleSet[T]) WithDocsURI(uri string) *WrapAnyRuleSet[T] { - return v.clone(wrapAnyWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), wrapAnyWithErrorConfig[T](v.errorConfig.WithDocs(uri))) + return v.clone(wrapAnyWithLabel[T](util.FormatStringArgLabel("WithDocsURI", uri)), wrapAnyWithErrorConfig[T](v.errorConfig.WithDocsURI(uri))) } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (v *WrapAnyRuleSet[T]) WithTraceURI(uri string) *WrapAnyRuleSet[T] { - return v.clone(wrapAnyWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), wrapAnyWithErrorConfig[T](v.errorConfig.WithTrace(uri))) + return v.clone(wrapAnyWithLabel[T](util.FormatStringArgLabel("WithTraceURI", uri)), wrapAnyWithErrorConfig[T](v.errorConfig.WithTraceURI(uri))) } // WithErrorCode returns a new RuleSet with a custom error code. diff --git a/pkg/testhelpers/mock.go b/pkg/testhelpers/mock.go index 0c145f1..5fdb08c 100644 --- a/pkg/testhelpers/mock.go +++ b/pkg/testhelpers/mock.go @@ -236,21 +236,21 @@ func (mockRuleSet *MockRuleSet[T]) Any() rules.RuleSet[any] { // WithErrorMessage returns a new RuleSet with custom short and long error messages. func (mockRuleSet *MockRuleSet[T]) WithErrorMessage(short, long string) *MockRuleSet[T] { newRuleSet := *mockRuleSet - newRuleSet.errorConfig = mockRuleSet.errorConfig.WithMessage(short, long) + newRuleSet.errorConfig = mockRuleSet.errorConfig.WithErrorMessage(short, long) return &newRuleSet } // WithDocsURI returns a new RuleSet with a custom documentation URI. func (mockRuleSet *MockRuleSet[T]) WithDocsURI(uri string) *MockRuleSet[T] { newRuleSet := *mockRuleSet - newRuleSet.errorConfig = mockRuleSet.errorConfig.WithDocs(uri) + newRuleSet.errorConfig = mockRuleSet.errorConfig.WithDocsURI(uri) return &newRuleSet } // WithTraceURI returns a new RuleSet with a custom trace/debug URI. func (mockRuleSet *MockRuleSet[T]) WithTraceURI(uri string) *MockRuleSet[T] { newRuleSet := *mockRuleSet - newRuleSet.errorConfig = mockRuleSet.errorConfig.WithTrace(uri) + newRuleSet.errorConfig = mockRuleSet.errorConfig.WithTraceURI(uri) return &newRuleSet }