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.

localMessages *and* localAttributes

See original GitHub issue

Hi,

I’m trying to figure out how to have local attributes names like you can set globally as I want friendly message for attribute names:

        <form-group
          class="col-md-6"
          name="telephoneNumber" 
          label="Telephone Number"
          font-awesome="fas fa-phone fa-rotate-90 fa-fw"
        >
          <b-form-input
            slot-scope="{ attrs, listeners }"
            v-bind="attrs"
            v-model="form.telephoneNumber"
            v-on="listeners" 
          /> 
        </form-group>

FYI, I’ve also had to add a prop to get bootstrap vue to take a font awesome class as a <slot name="label" won’t work in the main form:


<template>
  <b-form-group
    :invalid-feedback="firstErrorMessage"
    :state="isValid"
  >
    <label><i :class="fontAwesome"/> {{ label }}</label>
    <slot
      :attrs="{ state: isValid }"
      :listeners="{ input: () => preferredValidator.$touch() }"
    />
  </b-form-group>
</template>
<script>
import { singleErrorExtractorMixin } from "vuelidate-error-extractor"

export default {
  name: "FormElement",
  extends: singleErrorExtractorMixin,
  props: {
    fontAwesome: {
      type: String,
      default: "fas fa-envelope fa-fw"
    }
  }
}
</script>

screenshot_2018-10-15 gavin henry s profile - surevoip portal

Here’s my src/main.js snippet:

/* Actual messages presented to the user. Move to separate file and use i18n later */
const messages = {
  required: "Your {attribute} is required",
  email: "This is not a proper email address",
  minLength: "Your new password is not long enough",
  passwordComplexity:
    "Your new password is not complex enough. Please see above.",
  sameAsNewPassword:
    "Your confirmation password is not the same as your new password."
}

Vue.use(VuelidateErrorExtractor, {
  messages,
  attributes: {
    name: "Name",
    email: "Email",
    text: "Text",
    oldPassword: "old password",
    newPassword: "new password",
    confirmPassword: "password confirmation"
  }
})

Any tips?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dobromir-hristovcommented, Dec 26, 2018

@ghenry I was tweeking some things today and I remembered your issue. Why cant you use the attribute prop to pass an attribute per field? It has precedence over globally defined ones always.

1reaction
dobromir-hristovcommented, Oct 15, 2018

You want to be able to pass a set of local attributes per form-field? How is that easier than defining them globally, so you can re-use them?

You could overwrite resolvedAttribute computed property on your FormElement to check for a locally defined attributes prop.

https://github.com/dobromir-hristov/vuelidate-error-extractor/blob/master/src/single-error-extractor-mixin.js#L56-L58

Read more comments on GitHub >

github_iconTop Results From Across the Web

vuelidate-error-extractor/multi_error_extractor.md at master
An attributes prop cam be passed to identify each field's name in the form. Passing a local attributes prop will override the global...
Read more >
8.4 Configure logrotate - /var/log/localmessages | Tenable®
is the configuration file used to rotate log files created by rsyslog. ... large log files. Solution. Edit the /etc/logrotate.d/rsyslog file to include ......
Read more >
Untitled
Similarly, we explicitly distinguish between internal, local messages and the external as. imported/exported messages. Local messages allow for evolving the ...
Read more >
Towards an Object Petri Nets Model for Specifying and ...
Abstract. We present first results towards a tailored conceptual model for advanced distributed information systems regarded as open reactive.
Read more >
An Appropriate Semantics for Distributed Active Object-Oriented ...
Chg X Local Messages. subsort Prd X Local attributes. subsort Id.Prd X string X OId . (* Local attributes *) op b cikjH...
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