Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added german locale #442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions dist/locale/de.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Simple React Validator v1.6.2 | Created By Dockwa | MIT License | 2017 - Present
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['simple-react-validator'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('simple-react-validator'));
} else {
root.SimpleReactValidatorLocaleDe = factory(root.SimpleReactValidator);
}
}(this, function(SimpleReactValidator) {
"use strict";

// German
SimpleReactValidator.addLocale('de', {
accepted: ':attribute muss akzeptiert werden.',
after: ':attribute muss ein Datum nach dem :date sein.',
after_or_equal: ':attribute muss ein Datum nach oder am :date sein.',
alpha: ':attribute darf nur Buchstaben enthalten.',
alpha_space: ':attribute darf nur Buchstaben und Leerzeichen enthalten.',
alpha_num: ':attribute darf nur Buchstaben und Zahlen enthalten.',
alpha_num_space: ':attribute darf nur Buchstaben, Zahlen und Leerzeichen enthalten.',
alpha_num_dash: ':attribute darf nur Buchstaben, Zahlen, Unterstriche (_) und Bindestriche (-) enthalten.',
alpha_num_dash_space: ':attribute darf nur Buchstaben, Zahlen, Leerzeichen, Unterstriche (_) und Bindestriche (-) enthalten.',
array: ':attribute muss ausgewählte Elemente enthalten.',
before: ':attribute muss ein Datum vor dem :date sein.',
before_or_equal: ':attribute muss ein Dateum vor oder am :date sein.',
between: ':attribute muss zwischen :min und :max:type liegen.',
"boolean": ':attribute sollte ja oder nein lauten.',
card_exp: ':attribute muss ein gültiges Verfallsdatum sein.',
card_num: ':attribute muss eine gültige Kreditkartennummer sein.',
currency: ':attribute muss eine gültige Währung sein.',
date: ':attribute muss ein Datum sein.',
date_equals: ':attribute muss ein Datum sein das dem :date entspricht.',
email: ':attribute ist keine gültige E-Mail Adresse.',
"in": ':attribute muss ein Element von :values sein.',
integer: ':attribute muss eine Zahl sein.',
max: ':attribute darf :max:type nicht überschreiten.',
min: ':attribute darf :min:type nicht unterschreiten.',
not_in: 'Das Format :attribute ist ungültig.',
not_regex: ':attribute format ist ungültig.',
numeric: ':attribute muss eine Zahl sein.',
phone: ':attribute muss eine gültige Telefonnummer sein.',
regex: ':attribute format ist ungültig.',
required: ':attribute ist ein Pflichtfeld.',
size: ':attribute muss :size:type sein.',
string: ':attribute muss ein Text sein.',
"typeof": ':attribute ist nicht der richtige Typ für :type.',
url: ':attribute muss eine gültige URL sein.'
});
return null;
}));
2 changes: 2 additions & 0 deletions dist/locale/min/de.min.js

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

78 changes: 16 additions & 62 deletions dist/simple-react-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,71 +11,47 @@
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var SimpleReactValidator = /*#__PURE__*/function () {
function SimpleReactValidator() {
var _this = this;

var _options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

_classCallCheck(this, SimpleReactValidator);

_defineProperty(this, "showMessageFor", function (field) {
if (!_this.visibleFields.includes(field)) {
_this.visibleFields.push(field);
}

_this.helpers.forceUpdateIfNeeded();
});

_defineProperty(this, "hideMessageFor", function (field) {
var index = _this.visibleFields.indexOf(field);

if (index > -1) {
_this.visibleFields.splice(index, 1);
}

_this.helpers.forceUpdateIfNeeded();
});

_defineProperty(this, "helpers", {
parent: this,
passes: function passes(rule, value, params, rules) {
if (!rules.hasOwnProperty(rule)) {
console.error("Rule Not Found: There is no rule with the name ".concat(rule, "."));
return true;
}

if (!this.isRequired(rule, rules) && this.isBlank(value)) {
return true;
}

return rules[rule].rule(value, params, this.parent) !== false;
},
isRequired: function isRequired(rule, rules) {
Expand Down Expand Up @@ -156,7 +132,6 @@ var SimpleReactValidator = /*#__PURE__*/function () {
}
}
});

this.fields = {};
this.visibleFields = [];
this.errorMessages = {};
Expand Down Expand Up @@ -404,21 +379,23 @@ var SimpleReactValidator = /*#__PURE__*/function () {
return _this.helpers.testRegex(val, /^https?:\/\/[-a-z0-9@:%._\+~#=]{1,256}\.[a-z0-9()]{2,13}\b([-a-z0-9()@:%_\+.~#?&//=]*)$/i);
}
}
}, _options.validators || {}); // apply language
}, _options.validators || {});

// apply language
if (_options.locale && !SimpleReactValidator.locales.hasOwnProperty(_options.locale)) {
console.warn('Locale not found! Make sure it is spelled correctly and the locale file is loaded.');
}

var locale = SimpleReactValidator.locales[_options.locale] || {};
Object.keys(this.rules).forEach(function (key) {
_this.rules[key].message = locale[key] || _this.rules[key].message;
}); // apply default options
});

// apply default options
this.messages = _options.messages || {};
this.className = _options.className;
this.autoForceUpdate = _options.autoForceUpdate || false; // apply default element
this.autoForceUpdate = _options.autoForceUpdate || false;

// apply default element
if (_options.element === false) {
this.element = function (message) {
return message;
Expand All @@ -437,7 +414,6 @@ var SimpleReactValidator = /*#__PURE__*/function () {
};
}
}

_createClass(SimpleReactValidator, [{
key: "getErrorMessages",
value: function getErrorMessages() {
Expand All @@ -463,7 +439,6 @@ var SimpleReactValidator = /*#__PURE__*/function () {
return false;
}
}

return true;
}
}, {
Expand All @@ -481,7 +456,6 @@ var SimpleReactValidator = /*#__PURE__*/function () {
key: "messageWhenPresent",
value: function messageWhenPresent(message) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

if (!this.helpers.isBlank(message) && this.messagesShown) {
return this.helpers.element(message, options);
}
Expand All @@ -491,7 +465,6 @@ var SimpleReactValidator = /*#__PURE__*/function () {
value: function messageAlways(field, message) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
console.warn('The messageAlways() method is deprecated in SimpleReactValidator. Please see the documentation and switch to the messageWhenPresent() method.');

if (message && this.messagesShown) {
return this.helpers.element(message, options);
}
Expand All @@ -500,26 +473,20 @@ var SimpleReactValidator = /*#__PURE__*/function () {
key: "check",
value: function check(inputValue, validations) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

if (!Array.isArray(validations)) {
validations = validations.split('|');
}

var rules = options.validators ? _objectSpread(_objectSpread({}, this.rules), options.validators) : this.rules;

var _iterator = _createForOfIteratorHelper(validations),
_step;

_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var validation = _step.value;

var _this$helpers$normali = this.helpers.normalizeValues(inputValue, validation),
_this$helpers$normali2 = _slicedToArray(_this$helpers$normali, 3),
value = _this$helpers$normali2[0],
rule = _this$helpers$normali2[1],
params = _this$helpers$normali2[2];

_this$helpers$normali2 = _slicedToArray(_this$helpers$normali, 3),
value = _this$helpers$normali2[0],
rule = _this$helpers$normali2[1],
params = _this$helpers$normali2[2];
if (!this.helpers.passes(rule, value, params, rules)) {
return false;
}
Expand All @@ -529,7 +496,6 @@ var SimpleReactValidator = /*#__PURE__*/function () {
} finally {
_iterator.f();
}

return true;
}
}, {
Expand All @@ -538,36 +504,27 @@ var SimpleReactValidator = /*#__PURE__*/function () {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
this.errorMessages[field] = null;
this.fields[field] = true;

if (!Array.isArray(validations)) {
validations = validations.split('|');
}

var rules = options.validators ? _objectSpread(_objectSpread({}, this.rules), options.validators) : this.rules;

var _iterator2 = _createForOfIteratorHelper(validations),
_step2;

_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var validation = _step2.value;

var _this$helpers$normali3 = this.helpers.normalizeValues(inputValue, validation),
_this$helpers$normali4 = _slicedToArray(_this$helpers$normali3, 3),
value = _this$helpers$normali4[0],
rule = _this$helpers$normali4[1],
params = _this$helpers$normali4[2];

_this$helpers$normali4 = _slicedToArray(_this$helpers$normali3, 3),
value = _this$helpers$normali4[0],
rule = _this$helpers$normali4[1],
params = _this$helpers$normali4[2];
if (!this.helpers.passes(rule, value, params, rules)) {
this.fields[field] = false;
var message = this.helpers.message(rule, field, options, rules);

if (params.length > 0 && rules[rule].hasOwnProperty('messageReplace')) {
message = rules[rule].messageReplace(message, params);
}

this.errorMessages[field] = message;

if (this.messagesShown || this.visibleFields.includes(field)) {
return this.helpers.element(message, options);
}
Expand All @@ -585,12 +542,9 @@ var SimpleReactValidator = /*#__PURE__*/function () {
this.locales[lang] = messages;
}
}]);

return SimpleReactValidator;
}();

_defineProperty(SimpleReactValidator, "version", '1.5.1');

_defineProperty(SimpleReactValidator, "locales", {
'en': {}
});
Expand Down
Loading