Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNilErrorDetails = errors.New("error details is nil")
)
Functions ¶
This section is empty.
Types ¶
type DefaultEndParser ¶
type DefaultEndParser struct{}
DefaultEndParser is the default implementation of the EndParser interface
func NewDefaultEndParser ¶
func NewDefaultEndParser() DefaultEndParser
NewDefaultEndParser creates a new DefaultEndParser
Returns:
- DefaultEndParser: The new DefaultEndParser
func (DefaultEndParser) ParseValidations ¶
func (d DefaultEndParser) ParseValidations(structParsedValidations *govalidatormapperparser.StructParsedValidations) ( interface{}, error, )
ParseValidations parses the validations into a BadRequest
Parameters:
- structValidations: The root struct validations
Returns:
- interface{}: The parsed validations
- error: An error if the root struct validations are nil or if there was an error generating the BadRequest
type ErrorDetails ¶
type ErrorDetails struct {
// contains filtered or unexported fields
}
ErrorDetails is the struct for the error details wrapper
func NewErrorDetails ¶
func NewErrorDetails( structParsedValidations *govalidatormapperparser.StructParsedValidations, parentFieldName *string, fieldsViolations []*errdetails.BadRequest_FieldViolation, ) (*ErrorDetails, error)
NewErrorDetails adds the root struct parsed validations to the error details
Parameters:
- structParsedValidations: The root struct parsed validations to add
- parentFieldName: The parent field name to prefix to the field names
- fieldsViolations: The existing field violations to add to the error details
Returns:
- error: An error if the root struct parsed validations are nil or if the fields are already in the error details
func (*ErrorDetails) AddField ¶
func (e *ErrorDetails) AddField( fieldName string, fieldParsedValidations *govalidatormapperparser.FieldParsedValidations, ) error
AddField adds a field parsed validations to the error details
Parameters:
- fieldName: The name of the field
- fieldParsedValidations: The field parsed validations to add
Returns:
- error: An error if the field name is already in the error details
func (*ErrorDetails) AddNestedStruct ¶
func (e *ErrorDetails) AddNestedStruct( fieldName string, structParsedValidations *govalidatormapperparser.StructParsedValidations, ) error
AddNestedStruct adds a nested struct parsed validations to the error details
Parameters:
- fieldName: The name of the field that holds the nested struct
- structParsedValidations: The struct parsed validations to add
Returns:
- error: An error if the struct name is already in the error details
func (*ErrorDetails) GetBadRequest ¶
func (e *ErrorDetails) GetBadRequest() *errdetails.BadRequest
GetBadRequest gets the BadRequest from the ErrorDetails
Returns:
- *errdetails.BadRequest: The BadRequest from the ErrorDetails
Click to show internal directories.
Click to hide internal directories.