dobromir-hristov / vuelidate-error-extractor

Vuelidate form-group helper that extracts errors easily.
https://dobromir-hristov.github.io/vuelidate-error-extractor/
MIT License
138 stars 15 forks source link

More info #23

Closed afwn90cj93201nixr2e1re closed 5 years ago

afwn90cj93201nixr2e1re commented 5 years ago

image

Можно больше информации о том, что именно каждая из опций выполняет?

Чем

var script$4 = {
  inheritAttrs: false,
  components: {
    baseMultiErrorExtractor: baseMultiErrorExtractor
  }
};

Отличается от

var script$5 = {
  inheritAttrs: false,
  components: {
    baseMultiErrorExtractor: baseMultiErrorExtractor
  }
};

или

var script$3 = {
  name: 'baseMultiErrorExtractor',
  extends: multiErrorExtractorMixin
};

Ну и т.д

В документации очень кратко все.

image

afwn90cj93201nixr2e1re commented 5 years ago

Also if u can, add some examples for printing all error's for every field, like dat: https://buefy.org/extensions/veevalidate

afwn90cj93201nixr2e1re commented 5 years ago

Need something like simple input validation.

dobromir-hristov commented 5 years ago

So I am not expected to know Russian, so please write issues in English.

As for the multi error extractor, use the baseMultiErrorExtractor component for simple error looping, its just a data provider with a scoped slot.

The mixin is used to do more advanced stuff, as you have full control and access to the component's properties and methods.

Everything is explained in the docs, with examples.

afwn90cj93201nixr2e1re commented 5 years ago

Could u explain what MultierrorExtractor and SingleErrorExtractor are doing? What the differences, with examples(if u can).

Multierror displays all errors and singleerror display one error per input? Or what?

How we can just get error object with strings, without formwrappers and etc? There are we have a field:

<b-field :type="{ 'is-danger': $v.szLogin.$invalid }"
                                 :message="[ {'Username is bad': $v.szLogin.$invalid},{'Username required':!$v.szLogin.required}]"> <!-- etc -->

                            <b-input placeholder="Логин" v-model.trim="$v.szLogin.$model" autocomplete="off" novalidate></b-input>
                        </b-field>

How we can output error's like dat?

<b-field :type="{ 'is-danger': $v.szLogin.$invalid }"
                                 :message="$v.szLogin.errorsTextFromVuelidateErrorExtractor"> <!-- etc -->

                            <b-input placeholder="Логин" v-model.trim="$v.szLogin.$model" autocomplete="off" novalidate></b-input>
                        </b-field>

with formating like each error - <br> at the end or \n.

@dobromir-hristov

afwn90cj93201nixr2e1re commented 5 years ago
 <b-field :type="{ 'is-danger': $v.szLogin.$invalid, 'is-success': $v.szLogin.$invalid }"
                                 :message="loginmessage"> <!-- etc -->

Something like this.

    loginmessage() {
                //let some_array = [];
                //for(error in this.$v.szLogin.errorsaddedbyvueerrorextractor){
                //some_array[error].text = error.text;
                //some_array[error].param = error.param;
                //}
                //some_array[
                //{'{inputname} must be shorter than {min}':this.$v.szLogin.minLength},
                //{'{inputname} must be shorter than {max}':this.$v.szLogin.maxLength},
                //{'{inputname} must be filled':this.$v.szLogin.required},
                //]
                return `Username is bad, must be ${this.$v.szLogin.$params.minLength.min}`;
            },
dobromir-hristov commented 5 years ago

You are approaching things in a way, that this plugin is not intended to work with.

The multiErrorExtractor shows all errors for all fields in a form, the singleErrorExtractor all errors for a single field.

Extracting error messages happens ONLY with a wrapper component, via a mixin. You can use a wrapper component with a scoped slot to extract error fields if you want. There is no helper, like what you need.

There is a whole page on usage with other UI libraries, check it for more examples. https://dobromir-hristov.github.io/vuelidate-error-extractor/other_frameworks.html

The docs explain this well enough.

afwn90cj93201nixr2e1re commented 5 years ago

The multiErrorExtractor shows all errors for all fields in a form, the singleErrorExtractor all errors for a single field.

Thank's, that's all what i need to know. Ok, then can u explain when we must use BaseMulti, bp3, bp4, fn6 and etc?