simple-vue-validator icon indicating copy to clipboard operation
simple-vue-validator copied to clipboard

UMD build added

Open devistar opened this issue 8 years ago • 3 comments

I added UMD build and I updated the doc. It will be possible to use plugin directly inside a web page. It will also be possible via unpkg CDN to create jsfiddle. It will be easier for you to fix bugs.

devistar avatar Dec 13 '17 21:12 devistar

@devistar thanks very much for your contribution!

I would like to merge the UMD changes, but I afraid I cannot accept the codes that send AJAX request. Cuz there are many different ways and libraries (personally I use vue-resource) to talk to the server for async validation, and I don't think a validation library should make the decision on this. Besides that, I want to have as less dependencies as possible, so that the library is small and clean.

semisleep avatar Dec 17 '17 01:12 semisleep

I should have created a new branch for unique rule feature to not polute UMD build feature. But you can pull and rebase I added unique feature after.

What do you think about adding the way to create a custom persistant rule that could be chained ? Custom are good for unique use but a custom persistant rule is better for reusability. Then it would be possible for everyone to create unique rule using vue-resource or axios.

devistar avatar Dec 17 '17 01:12 devistar

I reset master branch to umd build state. On my project, I added a feature to your library allowing to add global custom validator. I did it by extending object and prototype but it can be easily added to your library.

I can do this :

addRule('unique', function(url, params) {
  // Rule context
  // Validation code...
  return this;
})

Then I chain my global custom validator in my project. For example :

validators: {
  username: function(value) {
    return Validator.value(value)
      .required()
      .minLength(5)
      .unique('users', { username: value });
  }
}
})

It works like a charm. If you are interested, I can add this. But you have to accept my current pull request and the next one.

devistar avatar Dec 20 '17 19:12 devistar