question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support attribute placeholder variations

See original GitHub issue

Hi @mikeerickson. For attribute placeholder, Laravel currently support 3 variations, which is :attribute, :ATTRIBUTE and :Attribute.

Fo reference: https://github.com/laravel/framework/blob/0c6f5f75bf0ba4d3307145c9d92ae022f60414be/src/Illuminate/Validation/Concerns/FormatsMessages.php#L289

It would be helpful if this library supports such feature as well. Below is the proposed patch that can provide the same feature:

_replacePlaceholders: function(rule, template, data) {
  var message, attribute;

  data.attribute = this._getAttributeName(rule.attribute);
  data.ATTRIBUTE = data.attribute.toLocaleUpperCase();
  data.Attribute = data.attribute.charAt(0).toLocaleUpperCase() + data.attribute.substring(1);
  data[rule.name] = data[rule.name] || rule.getParameters().join(',');

  if (typeof template === 'string' && typeof data === 'object') {
    message = template;

    for (attribute in data) {
      message = message.replace(new RegExp(':' + attribute, 'g'), data[attribute]);
    }
  }

  return message;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mikeericksoncommented, Feb 22, 2021

I have completed implementation of this feature and will be part of the upcoming v3.5 release, which I am to release by the end of the week.

1reaction
apihcommented, Feb 22, 2021

I need it to support a custom language file as well. Currently, I am loading the custom language file using Validator.setMessages() method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

placeholder - CSS: Cascading Style Sheets - MDN Web Docs
The ::placeholder CSS pseudo-element represents the placeholder text in an or element.
Read more >
How to support placeholder attribute in IE8 and 9
I simply have an input element with a value, and when the user clicks on the input element, it changes it to an...
Read more >
The Anatomy of Accessible Forms - Deque Systems
Instructions help users to submit forms successfully. ... The placeholder attribute specifies a short hint that describes the expected value ...
Read more >
Placeholder attribute? - Help & Support - Invision Community
I would like to add placeholder attributes to the registration form as members constantly enter the wrong information in the custom fields.
Read more >
Adding Attributes to Product Variations | WordPress.org
Hello everybody – we need help for the following problem: We run a shop with about 200 products – some of them variable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found