Skip to content

Commit

Permalink
chore(release): 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobromir Hristov committed Oct 10, 2017
1 parent 68e1555 commit 37dd4c6
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 45 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.2.0"></a>
# [1.2.0](https://github.com/dobromir-hristov/vuelidate-error-extractor/compare/v1.0.3...v1.2.0) (2017-10-10)


### Bug Fixes

* fix errors when trying to access messages that do not have props at all. ([68e1555](https://github.com/dobromir-hristov/vuelidate-error-extractor/commit/68e1555))


### Features

* support nested parameter dot notation and nested messages. ([4db24ee](https://github.com/dobromir-hristov/vuelidate-error-extractor/commit/4db24ee))



<a name="1.1.0"></a>
# [1.1.0](https://github.com/dobromir-hristov/vuelidate-error-extractor/compare/v1.0.3...v1.1.0) (2017-10-10)

Expand Down
31 changes: 23 additions & 8 deletions dist/message-extractor-mixin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vuelidate-error-extractor v1.1.0
* vuelidate-error-extractor v1.2.0
* (c) 2017 Dobromir Hristov
* Released under the MIT License.
*/
Expand All @@ -9,6 +9,8 @@
(factory((global.VuelidateErrorExtractorMixin = global.VuelidateErrorExtractorMixin || {})));
}(this, (function (exports) { 'use strict';

var idDev = "development" === 'development';

/**
* Deeply fetch dot notated strings from object.
* Has fallback if value does not exist
Expand All @@ -20,8 +22,22 @@
function get (string, object, fallback) {
if ( fallback === void 0 ) fallback = '';

var result = string.split('.').reduce(function (obj, current) { return obj[current]; }, object);
return typeof result === 'undefined' ? fallback : result
if (typeof string !== 'string') {
idDev && console.warn(("Expected a string in the first argument, got " + (typeof string)));
return fallback
}

if (typeof object !== 'object') {
idDev && console.warn(("Expected an Object/Array in the second argument, got " + (typeof object)));
return fallback
}

try {
return string.split('.').reduce(function (obj, current) { return obj[current] || ''; }, object)
} catch (err) {
idDev && console.warn(("[vuelidate-error-extractor]: " + err));
return fallback
}
}

/**
Expand All @@ -40,7 +56,7 @@ function template (template, object) {
}
var regx = /{(.*?)}/g;

return template.replace(regx, function (_, key) { return (get(key, object) || ''); })
return template.replace(regx, function (_, key) { return get(key, object) || ''; })
}

/**
Expand Down Expand Up @@ -103,7 +119,7 @@ var messageExtractorMixin = {
return this.activeErrors.length ? this.activeErrors[0] : ''
},
firstErrorMessage: function firstErrorMessage () {
return this.getErrorMessage(this.firstError.validationKey, this.firstError.params)
return this.hasErrors ? this.getErrorMessage(this.firstError.validationKey, this.firstError.params) : ''
},
hasErrors: function hasErrors () {
return this.validator.$error
Expand All @@ -117,9 +133,8 @@ var messageExtractorMixin = {
return this.$t(this.$vuelidateErrorExtractor.i18n + '.' + key, properties)
},
getPlainMessage: function getPlainMessage (key, properties) {
var msg = get(key, this.mergedMessages);
if (msg === '') {
"development" === 'development' && console.warn(("[vuelidate-error-extractor]: Key " + key + " is not present in error messages"));
var msg = get(key, this.mergedMessages, false);
if (!msg) {
return key
}
return template(msg, properties)
Expand Down
4 changes: 2 additions & 2 deletions dist/templates/bootstrap3.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/templates/bootstrap3.min.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/templates/foundation6.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/templates/foundation6.min.js.gz
Binary file not shown.
Loading

0 comments on commit 37dd4c6

Please sign in to comment.