You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default implementation of the attributeFormatter receives the indexed attribute name. For example something like addresses.5.line_one. This key is then used to directly fetch a matching value from the attributeNames.
Similar to the rule definitions, the attribute names there should support wildcard values.
This way we can assign a custom attribute name to all items in a collection at once.
To get around it I had to implement a custom attribute formatter that replaces the .{number}. with .*. and then use that to lookup. the correct value from the attributeNames.
validator.setAttributeNames(attributeNames)validator.setAttributeFormatter((attribute)=>{// Replaces `.{number}.` with `.*.` to try to match to a custom attribute nameconstwildcardAttribute=attribute.replace(/(.\d+.)/g,'.*.')// Replaces `._[` with `{blank space}` make the attribute a bit more presentableconstspacedAttribute=attribute.replace(/[_.[]/g,' ').replace(/]/g,'')returnattributeNames[wildcardAttribute]||spacedAttribute})
The text was updated successfully, but these errors were encountered:
oferrero
changed the title
Custom attributes names not supported when using wildcard rules
Custom attributes names not supported when using wildcard
Mar 12, 2021
@oferrero I am curious how your data (and rules) appear for this implementation? I can see what you are requesting, but would like to see your implementation so that I can better advise (and potentially adjust) the internals.
The default implementation of the
attributeFormatter
receives the indexed attribute name. For example something likeaddresses.5.line_one
. This key is then used to directly fetch a matching value from theattributeNames
.Similar to the rule definitions, the attribute names there should support wildcard values.
This way we can assign a custom attribute name to all items in a collection at once.
To get around it I had to implement a custom attribute formatter that replaces the
.{number}.
with.*.
and then use that to lookup. the correct value from theattributeNames
.The text was updated successfully, but these errors were encountered: