Open ocelot93 opened 2 years ago
@ocelot93 Did you find a workaround for this limitation -- in particular getting the index?
@marshallford apologize for a delayed answer, I didn't find any solution for this, have to prematurely prepare a map through which I then seek for the needed value
Package version eg. v9, v10:
v10
Issue, Question or Enhancement:
I am working on validation for incoming spreadsheets. Validator has some custom tags, registered through either
RegisterValidation
orRegisterValidationCtx
funcs. Each validation error is being translated, but I can't operate anything butFieldError
interface while registering a translation.It would be useful to add methods for
FieldError
interface such asStructLevel
has, in case anyone wants to be able to work with reflection, e.g. to retrieve Top struct, or to get a struct tag. Because now for simply obtaining a slice index for occurred error, it's necessary to parsefe.Namespace()
stringExample
Task: retrieve a spreadsheet name and spreadsheet row number for occurred error Current implementation: parsing
fe.Namespace()
string obtaining parent struct's name and slice index of occurred error, then retrieving calculated map fromctx
Proposal: simply retrieve parent struct's tag using reflection; for row number - retrieve index of slice also using reflection