@fkui/i18next-translate 5.45.0 → 5.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +203 -98
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +203 -98
- package/dist/esm/index.js.map +1 -1
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -4197,7 +4197,7 @@ function requireDayjs_min () {
|
|
|
4197
4197
|
if (hasRequiredDayjs_min) return dayjs_min$1.exports;
|
|
4198
4198
|
hasRequiredDayjs_min = 1;
|
|
4199
4199
|
(function (module, exports) {
|
|
4200
|
-
!function(t,e){module.exports=e();}(dayjs_min,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return
|
|
4200
|
+
!function(t,e){module.exports=e();}(dayjs_min,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return undefined===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,true),this.parse(t),this.$x=this.$x||t.x||{},this[p]=true;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,false)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case "YY":return String(e.$y).slice(-2);case "YYYY":return b.s(e.$y,4,"0");case "M":return a+1;case "MM":return b.s(a+1,2,"0");case "MMM":return h(n.monthsShort,a,c,3);case "MMMM":return h(c,a);case "D":return e.$D;case "DD":return b.s(e.$D,2,"0");case "d":return String(e.$W);case "dd":return h(n.weekdaysMin,e.$W,o,2);case "ddd":return h(n.weekdaysShort,e.$W,o,3);case "dddd":return o[e.$W];case "H":return String(s);case "HH":return b.s(s,2,"0");case "h":return d(1);case "hh":return d(2);case "a":return $(s,u,true);case "A":return $(s,u,false);case "m":return String(u);case "mm":return b.s(u,2,"0");case "s":return String(e.$s);case "ss":return b.s(e.$s,2,"0");case "SSS":return b.s(e.$ms,3,"0");case "Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,true);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=true),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
4201
4201
|
} (dayjs_min$1));
|
|
4202
4202
|
return dayjs_min$1.exports;
|
|
4203
4203
|
}
|
|
@@ -4215,7 +4215,7 @@ function requireSv () {
|
|
|
4215
4215
|
if (hasRequiredSv) return sv$1.exports;
|
|
4216
4216
|
hasRequiredSv = 1;
|
|
4217
4217
|
(function (module, exports) {
|
|
4218
|
-
!function(e,t){module.exports=t(requireDayjs_min());}(sv,(function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e),d={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return "["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return a.default.locale(d,null
|
|
4218
|
+
!function(e,t){module.exports=t(requireDayjs_min());}(sv,(function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e),d={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return "["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return a.default.locale(d,null,true),d}));
|
|
4219
4219
|
} (sv$1));
|
|
4220
4220
|
return sv$1.exports;
|
|
4221
4221
|
}
|
|
@@ -4232,7 +4232,7 @@ function requireWeekOfYear () {
|
|
|
4232
4232
|
if (hasRequiredWeekOfYear) return weekOfYear$2.exports;
|
|
4233
4233
|
hasRequiredWeekOfYear = 1;
|
|
4234
4234
|
(function (module, exports) {
|
|
4235
|
-
!function(e,t){module.exports=t();}(weekOfYear$1,(function(){var e="week",t="year";return function(i,n,r){var f=n.prototype;f.week=function(i){if(
|
|
4235
|
+
!function(e,t){module.exports=t();}(weekOfYear$1,(function(){var e="week",t="year";return function(i,n,r){var f=n.prototype;f.week=function(i){if(undefined===i&&(i=null),null!==i)return this.add(7*(i-this.week()),"day");var n=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var f=r(this).startOf(t).add(1,t).date(n),s=r(this).endOf(e);if(f.isBefore(s))return 1}var a=r(this).startOf(t).date(n).startOf(e).subtract(1,"millisecond"),o=this.diff(a,e,true);return o<0?r(this).startOf("week").week():Math.ceil(o)},f.weeks=function(e){return undefined===e&&(e=null),this.week(e)};}}));
|
|
4236
4236
|
} (weekOfYear$2));
|
|
4237
4237
|
return weekOfYear$2.exports;
|
|
4238
4238
|
}
|
|
@@ -4417,7 +4417,7 @@ const formatter = {
|
|
|
4417
4417
|
class FDate {
|
|
4418
4418
|
value;
|
|
4419
4419
|
constructor(value) {
|
|
4420
|
-
this.value = dayjs(value, ISO8601_YYYY_MM_DD, true);
|
|
4420
|
+
this.value = dayjs(value, ISO8601_YYYY_MM_DD, true).startOf("day");
|
|
4421
4421
|
}
|
|
4422
4422
|
/**
|
|
4423
4423
|
* Create {@link FDate} with an invalid state.
|
|
@@ -4721,7 +4721,7 @@ class FDate {
|
|
|
4721
4721
|
if (typeof rhs === "string") {
|
|
4722
4722
|
rhs = FDate.fromIso(rhs);
|
|
4723
4723
|
}
|
|
4724
|
-
return this.value.isBefore(rhs.value);
|
|
4724
|
+
return this.value.isBefore(rhs.value, "day");
|
|
4725
4725
|
}
|
|
4726
4726
|
/**
|
|
4727
4727
|
* Returns true if this date is after given date.
|
|
@@ -4732,7 +4732,7 @@ class FDate {
|
|
|
4732
4732
|
if (typeof rhs === "string") {
|
|
4733
4733
|
rhs = FDate.fromIso(rhs);
|
|
4734
4734
|
}
|
|
4735
|
-
return this.value.isAfter(rhs.value);
|
|
4735
|
+
return this.value.isAfter(rhs.value, "day");
|
|
4736
4736
|
}
|
|
4737
4737
|
/**
|
|
4738
4738
|
* Compares two {@link FDate} objects. Returns and integer indicating whenever
|
|
@@ -4771,10 +4771,10 @@ class FDate {
|
|
|
4771
4771
|
return -1;
|
|
4772
4772
|
}
|
|
4773
4773
|
}
|
|
4774
|
-
if (a.
|
|
4774
|
+
if (a.equals(b)) {
|
|
4775
4775
|
return 0;
|
|
4776
4776
|
}
|
|
4777
|
-
else if (a.
|
|
4777
|
+
else if (a.isBefore(b)) {
|
|
4778
4778
|
return -1;
|
|
4779
4779
|
}
|
|
4780
4780
|
else {
|
|
@@ -4817,6 +4817,26 @@ class FDate {
|
|
|
4817
4817
|
}
|
|
4818
4818
|
}
|
|
4819
4819
|
|
|
4820
|
+
/**
|
|
4821
|
+
* @public
|
|
4822
|
+
*/
|
|
4823
|
+
function parseDate(value) {
|
|
4824
|
+
if (isEmpty(value)) {
|
|
4825
|
+
return undefined;
|
|
4826
|
+
}
|
|
4827
|
+
const normalized = normalizeDateFormat(value);
|
|
4828
|
+
if (!normalized) {
|
|
4829
|
+
return undefined;
|
|
4830
|
+
}
|
|
4831
|
+
const date = FDate.fromIso(normalized);
|
|
4832
|
+
if (date.isValid()) {
|
|
4833
|
+
return date.toString();
|
|
4834
|
+
}
|
|
4835
|
+
else {
|
|
4836
|
+
return undefined;
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
|
|
4820
4840
|
/**
|
|
4821
4841
|
* Strips all whitespace from the text (not only leading and trailing)
|
|
4822
4842
|
*
|
|
@@ -4943,6 +4963,18 @@ function parsePersonnummerLuhn(value) {
|
|
|
4943
4963
|
}
|
|
4944
4964
|
return parsed;
|
|
4945
4965
|
}
|
|
4966
|
+
/**
|
|
4967
|
+
* Formats personnummer to a 8-digit date.
|
|
4968
|
+
*
|
|
4969
|
+
* @public
|
|
4970
|
+
*/
|
|
4971
|
+
function formatPersonnummerToDate(value) {
|
|
4972
|
+
const datePart = parseDate(parsePersonnummer(value)?.slice(0, 8) || "");
|
|
4973
|
+
if (!datePart) {
|
|
4974
|
+
return undefined;
|
|
4975
|
+
}
|
|
4976
|
+
return FDate.fromIso(datePart);
|
|
4977
|
+
}
|
|
4946
4978
|
|
|
4947
4979
|
const PLUSGIRO_REGEXP = /^\d{1,7}[-]?\d{1}$/;
|
|
4948
4980
|
function hyphenShouldBeAdded(value) {
|
|
@@ -5110,16 +5142,16 @@ function getErrorMessages() {
|
|
|
5110
5142
|
return ValidationErrorMessageBuilder.create()
|
|
5111
5143
|
.map("bankAccountNumber", "Kontonumret är inte rätt ifyllt. Kolla att det stämmer.")
|
|
5112
5144
|
.mapCombined("required", "bankAccountNumber", "Fyll i ett kontonummer.")
|
|
5113
|
-
.map("bankgiro", "
|
|
5145
|
+
.map("bankgiro", "Fyll i bankgironumret med sju eller åtta siffror och bindestreck.")
|
|
5114
5146
|
.mapCombined("required", "bankgiro", "Fyll i bankgironumret.")
|
|
5115
5147
|
.mapCombined("maxLength", "bankgiro", "Bankgironumret kan inte ha mer än 9 tecken.")
|
|
5116
5148
|
.map("clearingNumber", "Clearingnumret är inte rätt ifyllt. Kolla att det stämmer.")
|
|
5117
5149
|
.mapCombined("required", "clearingNumber", "Fyll i ett clearingnummer.")
|
|
5118
5150
|
.map("currency", "Fyll i ett belopp.")
|
|
5119
5151
|
.mapCombined("required", "currency", "Fyll i ett belopp.")
|
|
5120
|
-
.map("date", "Du har
|
|
5152
|
+
.map("date", "Du har fyllt i ett felaktigt datum.")
|
|
5121
5153
|
.mapCombined("required", "date", "Välj ett datum.")
|
|
5122
|
-
.map("dateFormat", "
|
|
5154
|
+
.map("dateFormat", "Fyll i datumet med åtta siffror.")
|
|
5123
5155
|
.map("decimal", "Fyll i ett värde med rätt antal decimaler.")
|
|
5124
5156
|
.map("email", "Mejladressen är inte korrekt ifylld.")
|
|
5125
5157
|
.mapCombined("required", "email", "Fyll i en mejladress.")
|
|
@@ -5146,9 +5178,9 @@ function getErrorMessages() {
|
|
|
5146
5178
|
.mapCombined("required", "percent", "Fyll i en siffra.")
|
|
5147
5179
|
.mapCombined("minValue", "percent", "Fyll i en högre siffra.")
|
|
5148
5180
|
.mapCombined("maxValue", "percent", "Fyll i en lägre siffra.")
|
|
5149
|
-
.map("personnummerFormat", "
|
|
5150
|
-
.mapCombined("required", "personnummerFormat", "
|
|
5151
|
-
.mapCombined("maxLength", "personnummerFormat", "
|
|
5181
|
+
.map("personnummerFormat", "Fyll i personnumret med 10 siffror.")
|
|
5182
|
+
.mapCombined("required", "personnummerFormat", "Fyll i personnumret med 10 siffror.")
|
|
5183
|
+
.mapCombined("maxLength", "personnummerFormat", "Fyll i personnumret med 10 siffror.")
|
|
5152
5184
|
.map("personnummerLuhn", "Kolla att personnumret stämmer.")
|
|
5153
5185
|
.map("postalCode", "Fyll i postnumret med fem siffror.")
|
|
5154
5186
|
.mapCombined("required", "postalCode", "Fyll i ett postnummer.")
|
|
@@ -5156,7 +5188,7 @@ function getErrorMessages() {
|
|
|
5156
5188
|
.map("phoneNumber", "Telefonnumret är inte rätt ifyllt.")
|
|
5157
5189
|
.mapCombined("required", "phoneNumber", "Fyll i ett telefonnummer.")
|
|
5158
5190
|
.mapCombined("matches", "phoneNumber", "Kolla att telefonnumret stämmer.")
|
|
5159
|
-
.map("plusgiro", "
|
|
5191
|
+
.map("plusgiro", "Fyll i plusgironumret med siffror och bindestreck.")
|
|
5160
5192
|
.mapCombined("required", "plusgiro", "Fyll i plusgironumret.")
|
|
5161
5193
|
.mapCombined("maxLength", "plusgiro", "Plusgironumret kan inte ha mer än 11 tecken.")
|
|
5162
5194
|
.map("matches", "Fälten stämmer inte överens.")
|
|
@@ -5167,6 +5199,7 @@ function getErrorMessages() {
|
|
|
5167
5199
|
.map("invalidDates", "Du kan inte välja det här datumet.")
|
|
5168
5200
|
.map("invalidWeekdays", "Du kan inte välja det här datumet.")
|
|
5169
5201
|
.map("whitelist", 'Fältet innehåller otillåtna tecken. Exempel på ogiltiga tecken är /, % och ".')
|
|
5202
|
+
.map("allowList", "Välj ett av alternativen i listan.")
|
|
5170
5203
|
.build();
|
|
5171
5204
|
}
|
|
5172
5205
|
|
|
@@ -5307,6 +5340,9 @@ function getElementType(element) {
|
|
|
5307
5340
|
* @param element - Element to test
|
|
5308
5341
|
*/
|
|
5309
5342
|
function isValidatableHTMLElement(element) {
|
|
5343
|
+
if (element.classList.contains("card")) {
|
|
5344
|
+
return true;
|
|
5345
|
+
}
|
|
5310
5346
|
return (element instanceof HTMLInputElement ||
|
|
5311
5347
|
element instanceof HTMLTextAreaElement ||
|
|
5312
5348
|
element instanceof HTMLSelectElement ||
|
|
@@ -5727,14 +5763,20 @@ class ValidationServiceImpl {
|
|
|
5727
5763
|
return this.hasValue(fieldsetInputElement);
|
|
5728
5764
|
});
|
|
5729
5765
|
}
|
|
5766
|
+
if (element instanceof HTMLDivElement) {
|
|
5767
|
+
return false;
|
|
5768
|
+
}
|
|
5730
5769
|
return Boolean(isRadiobuttonOrCheckbox(element)
|
|
5731
5770
|
? element.checked
|
|
5732
5771
|
: element.value);
|
|
5733
5772
|
}
|
|
5734
5773
|
getValue(element) {
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5774
|
+
if ("value" in element) {
|
|
5775
|
+
return element.value.trim();
|
|
5776
|
+
}
|
|
5777
|
+
else {
|
|
5778
|
+
return "";
|
|
5779
|
+
}
|
|
5738
5780
|
}
|
|
5739
5781
|
validateAll(element, validationState, validators, validatorConfigs) {
|
|
5740
5782
|
if (validationState.serverError) {
|
|
@@ -5744,7 +5786,7 @@ class ValidationServiceImpl {
|
|
|
5744
5786
|
};
|
|
5745
5787
|
}
|
|
5746
5788
|
/* if the element is disabled we always consider it to be valid */
|
|
5747
|
-
if (element.disabled) {
|
|
5789
|
+
if ("disabled" in element && element.disabled) {
|
|
5748
5790
|
return {
|
|
5749
5791
|
isValid: true,
|
|
5750
5792
|
validationMessage: "",
|
|
@@ -5805,7 +5847,9 @@ class ValidationServiceImpl {
|
|
|
5805
5847
|
detail: validityEvent,
|
|
5806
5848
|
});
|
|
5807
5849
|
for (const affectedElement of affectedElements) {
|
|
5808
|
-
affectedElement
|
|
5850
|
+
if ("setCustomValidity" in affectedElement) {
|
|
5851
|
+
affectedElement.setCustomValidity(validityEvent.validationMessage);
|
|
5852
|
+
}
|
|
5809
5853
|
affectedElement.setAttribute("aria-invalid", validField.toString());
|
|
5810
5854
|
}
|
|
5811
5855
|
element.dispatchEvent(event);
|
|
@@ -5819,6 +5863,21 @@ class ValidationServiceImpl {
|
|
|
5819
5863
|
*/
|
|
5820
5864
|
const ValidationService = new ValidationServiceImpl();
|
|
5821
5865
|
|
|
5866
|
+
/**
|
|
5867
|
+
* @public
|
|
5868
|
+
*/
|
|
5869
|
+
const allowListValidator = {
|
|
5870
|
+
name: "allowList",
|
|
5871
|
+
validation(value, element, config) {
|
|
5872
|
+
if (isEmpty(value) ||
|
|
5873
|
+
config.list === undefined ||
|
|
5874
|
+
config.list.length === 0) {
|
|
5875
|
+
return true;
|
|
5876
|
+
}
|
|
5877
|
+
return config.list.includes(value);
|
|
5878
|
+
},
|
|
5879
|
+
};
|
|
5880
|
+
|
|
5822
5881
|
const bankAccountNumberValidator = {
|
|
5823
5882
|
name: "bankAccountNumber",
|
|
5824
5883
|
validation(value) {
|
|
@@ -5833,6 +5892,26 @@ const bankgiroValidator = {
|
|
|
5833
5892
|
},
|
|
5834
5893
|
};
|
|
5835
5894
|
|
|
5895
|
+
function toArray(value) {
|
|
5896
|
+
if (Array.isArray(value)) {
|
|
5897
|
+
return value;
|
|
5898
|
+
}
|
|
5899
|
+
else {
|
|
5900
|
+
return [value];
|
|
5901
|
+
}
|
|
5902
|
+
}
|
|
5903
|
+
const blacklistValidator = {
|
|
5904
|
+
name: "blacklist",
|
|
5905
|
+
validation(value, _element, config) {
|
|
5906
|
+
if (!config.values) {
|
|
5907
|
+
throw new Error("config.exclude must have values");
|
|
5908
|
+
}
|
|
5909
|
+
const values = toArray(config.values);
|
|
5910
|
+
const found = values.some((it) => String(it) === value);
|
|
5911
|
+
return !found;
|
|
5912
|
+
},
|
|
5913
|
+
};
|
|
5914
|
+
|
|
5836
5915
|
const clearingNumberValidator = {
|
|
5837
5916
|
name: "clearingNumber",
|
|
5838
5917
|
validation(value) {
|
|
@@ -5840,6 +5919,13 @@ const clearingNumberValidator = {
|
|
|
5840
5919
|
},
|
|
5841
5920
|
};
|
|
5842
5921
|
|
|
5922
|
+
const currencyValidator = {
|
|
5923
|
+
name: "currency",
|
|
5924
|
+
validation(value) {
|
|
5925
|
+
return isEmpty(value) || isSet(parseNumber(value));
|
|
5926
|
+
},
|
|
5927
|
+
};
|
|
5928
|
+
|
|
5843
5929
|
const dateValidator = {
|
|
5844
5930
|
name: "date",
|
|
5845
5931
|
validation(value) {
|
|
@@ -5893,26 +5979,6 @@ const decimalValidator = {
|
|
|
5893
5979
|
},
|
|
5894
5980
|
};
|
|
5895
5981
|
|
|
5896
|
-
function toArray(value) {
|
|
5897
|
-
if (Array.isArray(value)) {
|
|
5898
|
-
return value;
|
|
5899
|
-
}
|
|
5900
|
-
else {
|
|
5901
|
-
return [value];
|
|
5902
|
-
}
|
|
5903
|
-
}
|
|
5904
|
-
const blacklistValidator = {
|
|
5905
|
-
name: "blacklist",
|
|
5906
|
-
validation(value, _element, config) {
|
|
5907
|
-
if (!config.values) {
|
|
5908
|
-
throw new Error("config.exclude must have values");
|
|
5909
|
-
}
|
|
5910
|
-
const values = toArray(config.values);
|
|
5911
|
-
const found = values.some((it) => String(it) === value);
|
|
5912
|
-
return !found;
|
|
5913
|
-
},
|
|
5914
|
-
};
|
|
5915
|
-
|
|
5916
5982
|
const emailValidator = {
|
|
5917
5983
|
name: "email",
|
|
5918
5984
|
validation(value, _element, config) {
|
|
@@ -5922,6 +5988,35 @@ const emailValidator = {
|
|
|
5922
5988
|
},
|
|
5923
5989
|
};
|
|
5924
5990
|
|
|
5991
|
+
/**
|
|
5992
|
+
* @internal
|
|
5993
|
+
*/
|
|
5994
|
+
function numberValidator$1(value, config, name, compare) {
|
|
5995
|
+
if (value === "") {
|
|
5996
|
+
return true;
|
|
5997
|
+
}
|
|
5998
|
+
const limit = config[name];
|
|
5999
|
+
if (!isSet(limit)) {
|
|
6000
|
+
return false;
|
|
6001
|
+
}
|
|
6002
|
+
const limitAsNumber = parseNumber(String(config[name]));
|
|
6003
|
+
if (limitAsNumber === undefined) {
|
|
6004
|
+
throw new Error(`config.${String(name)} must be a number`);
|
|
6005
|
+
}
|
|
6006
|
+
const valueAsNumber = parseNumber(value);
|
|
6007
|
+
if (valueAsNumber === undefined) {
|
|
6008
|
+
return false;
|
|
6009
|
+
}
|
|
6010
|
+
return compare(valueAsNumber, limitAsNumber);
|
|
6011
|
+
}
|
|
6012
|
+
|
|
6013
|
+
const greaterThanValidator = {
|
|
6014
|
+
name: "greaterThan",
|
|
6015
|
+
validation(value, _element, config) {
|
|
6016
|
+
return numberValidator$1(value, config, "limit", (value, limit) => value > limit);
|
|
6017
|
+
},
|
|
6018
|
+
};
|
|
6019
|
+
|
|
5925
6020
|
const NUMBER_REGEXP = /^([-−]?[0-9]+)?$/;
|
|
5926
6021
|
const integerValidator = {
|
|
5927
6022
|
name: "integer",
|
|
@@ -5979,35 +6074,6 @@ const invalidWeekdaysValidator = {
|
|
|
5979
6074
|
},
|
|
5980
6075
|
};
|
|
5981
6076
|
|
|
5982
|
-
/**
|
|
5983
|
-
* @internal
|
|
5984
|
-
*/
|
|
5985
|
-
function numberValidator$1(value, config, name, compare) {
|
|
5986
|
-
if (value === "") {
|
|
5987
|
-
return true;
|
|
5988
|
-
}
|
|
5989
|
-
const limit = config[name];
|
|
5990
|
-
if (!isSet(limit)) {
|
|
5991
|
-
return false;
|
|
5992
|
-
}
|
|
5993
|
-
const limitAsNumber = parseNumber(String(config[name]));
|
|
5994
|
-
if (limitAsNumber === undefined) {
|
|
5995
|
-
throw new Error(`config.${String(name)} must be a number`);
|
|
5996
|
-
}
|
|
5997
|
-
const valueAsNumber = parseNumber(value);
|
|
5998
|
-
if (valueAsNumber === undefined) {
|
|
5999
|
-
return false;
|
|
6000
|
-
}
|
|
6001
|
-
return compare(valueAsNumber, limitAsNumber);
|
|
6002
|
-
}
|
|
6003
|
-
|
|
6004
|
-
const greaterThanValidator = {
|
|
6005
|
-
name: "greaterThan",
|
|
6006
|
-
validation(value, _element, config) {
|
|
6007
|
-
return numberValidator$1(value, config, "limit", (value, limit) => value > limit);
|
|
6008
|
-
},
|
|
6009
|
-
};
|
|
6010
|
-
|
|
6011
6077
|
const lessThanValidator = {
|
|
6012
6078
|
name: "lessThan",
|
|
6013
6079
|
validation(value, _element, config) {
|
|
@@ -6028,6 +6094,22 @@ const matchesValidator = {
|
|
|
6028
6094
|
},
|
|
6029
6095
|
};
|
|
6030
6096
|
|
|
6097
|
+
const maxDateValidator = {
|
|
6098
|
+
name: "maxDate",
|
|
6099
|
+
validation(value, _element, config) {
|
|
6100
|
+
if (isEmpty(value)) {
|
|
6101
|
+
return true;
|
|
6102
|
+
}
|
|
6103
|
+
const normalizedValue = normalizeDateFormat(value);
|
|
6104
|
+
if (!normalizedValue) {
|
|
6105
|
+
return false;
|
|
6106
|
+
}
|
|
6107
|
+
const parsed = FDate.fromIso(normalizedValue);
|
|
6108
|
+
const limit = FDate.fromIso(validLimit(config.limit));
|
|
6109
|
+
return parsed.equals(limit) || parsed.isBefore(limit);
|
|
6110
|
+
},
|
|
6111
|
+
};
|
|
6112
|
+
|
|
6031
6113
|
const maxLengthValidator = {
|
|
6032
6114
|
name: "maxLength",
|
|
6033
6115
|
validation(value, _element, config) {
|
|
@@ -6058,22 +6140,6 @@ const minDateValidator = {
|
|
|
6058
6140
|
},
|
|
6059
6141
|
};
|
|
6060
6142
|
|
|
6061
|
-
const maxDateValidator = {
|
|
6062
|
-
name: "maxDate",
|
|
6063
|
-
validation(value, _element, config) {
|
|
6064
|
-
if (isEmpty(value)) {
|
|
6065
|
-
return true;
|
|
6066
|
-
}
|
|
6067
|
-
const normalizedValue = normalizeDateFormat(value);
|
|
6068
|
-
if (!normalizedValue) {
|
|
6069
|
-
return false;
|
|
6070
|
-
}
|
|
6071
|
-
const parsed = FDate.fromIso(normalizedValue);
|
|
6072
|
-
const limit = FDate.fromIso(validLimit(config.limit));
|
|
6073
|
-
return parsed.equals(limit) || parsed.isBefore(limit);
|
|
6074
|
-
},
|
|
6075
|
-
};
|
|
6076
|
-
|
|
6077
6143
|
const minLengthValidator = {
|
|
6078
6144
|
name: "minLength",
|
|
6079
6145
|
validation(value, _element, config) {
|
|
@@ -6095,13 +6161,6 @@ const numberValidator = {
|
|
|
6095
6161
|
},
|
|
6096
6162
|
};
|
|
6097
6163
|
|
|
6098
|
-
const currencyValidator = {
|
|
6099
|
-
name: "currency",
|
|
6100
|
-
validation(value) {
|
|
6101
|
-
return isEmpty(value) || isSet(parseNumber(value));
|
|
6102
|
-
},
|
|
6103
|
-
};
|
|
6104
|
-
|
|
6105
6164
|
const organisationsnummerValidator = {
|
|
6106
6165
|
name: "organisationsnummer",
|
|
6107
6166
|
validation(value) {
|
|
@@ -6135,6 +6194,48 @@ const personnummerLuhnValidator = {
|
|
|
6135
6194
|
},
|
|
6136
6195
|
};
|
|
6137
6196
|
|
|
6197
|
+
const personnummerNotSame = {
|
|
6198
|
+
name: "personnummerNotSame",
|
|
6199
|
+
validation(value, _element, config) {
|
|
6200
|
+
const valuePnr = parsePersonnummer(String(value));
|
|
6201
|
+
if (!valuePnr) {
|
|
6202
|
+
return true;
|
|
6203
|
+
}
|
|
6204
|
+
const otherFieldPnr = parsePersonnummer(String(config.otherField));
|
|
6205
|
+
if (!otherFieldPnr) {
|
|
6206
|
+
return true;
|
|
6207
|
+
}
|
|
6208
|
+
if (valuePnr === otherFieldPnr) {
|
|
6209
|
+
return false;
|
|
6210
|
+
}
|
|
6211
|
+
return true;
|
|
6212
|
+
},
|
|
6213
|
+
};
|
|
6214
|
+
|
|
6215
|
+
const personnummerOlder = {
|
|
6216
|
+
name: "personnummerOlder",
|
|
6217
|
+
validation(value, _element, config) {
|
|
6218
|
+
const valueAsDate = formatPersonnummerToDate(value);
|
|
6219
|
+
const otherAsDate = formatPersonnummerToDate(String(config.otherField));
|
|
6220
|
+
if (!valueAsDate || !otherAsDate) {
|
|
6221
|
+
return true;
|
|
6222
|
+
}
|
|
6223
|
+
return FDate.compare(valueAsDate, otherAsDate) !== 1;
|
|
6224
|
+
},
|
|
6225
|
+
};
|
|
6226
|
+
|
|
6227
|
+
const personnummerYounger = {
|
|
6228
|
+
name: "personnummerYounger",
|
|
6229
|
+
validation(value, _element, config) {
|
|
6230
|
+
const valueAsDate = formatPersonnummerToDate(value);
|
|
6231
|
+
const otherAsDate = formatPersonnummerToDate(String(config.otherField));
|
|
6232
|
+
if (!valueAsDate || !otherAsDate) {
|
|
6233
|
+
return true;
|
|
6234
|
+
}
|
|
6235
|
+
return FDate.compare(valueAsDate, otherAsDate) !== -1;
|
|
6236
|
+
},
|
|
6237
|
+
};
|
|
6238
|
+
|
|
6138
6239
|
const PHONE_NUMBER_REGEXP = /^(\+?[-_/() ]*(\d[-_/() ]*?){3,17})$/;
|
|
6139
6240
|
const phoneNumberValidator = {
|
|
6140
6241
|
name: "phoneNumber",
|
|
@@ -6201,32 +6302,36 @@ const whitelistValidator = {
|
|
|
6201
6302
|
},
|
|
6202
6303
|
};
|
|
6203
6304
|
|
|
6305
|
+
ValidationService.registerValidator(allowListValidator);
|
|
6204
6306
|
ValidationService.registerValidator(bankAccountNumberValidator);
|
|
6205
6307
|
ValidationService.registerValidator(bankgiroValidator);
|
|
6308
|
+
ValidationService.registerValidator(blacklistValidator);
|
|
6206
6309
|
ValidationService.registerValidator(clearingNumberValidator);
|
|
6310
|
+
ValidationService.registerValidator(currencyValidator);
|
|
6207
6311
|
ValidationService.registerValidator(dateFormatValidator);
|
|
6208
6312
|
ValidationService.registerValidator(dateValidator);
|
|
6209
6313
|
ValidationService.registerValidator(decimalValidator);
|
|
6210
|
-
ValidationService.registerValidator(blacklistValidator);
|
|
6211
6314
|
ValidationService.registerValidator(emailValidator);
|
|
6212
|
-
ValidationService.registerValidator(integerValidator);
|
|
6213
6315
|
ValidationService.registerValidator(greaterThanValidator);
|
|
6316
|
+
ValidationService.registerValidator(integerValidator);
|
|
6214
6317
|
ValidationService.registerValidator(invalidDatesValidator);
|
|
6215
6318
|
ValidationService.registerValidator(invalidWeekdaysValidator);
|
|
6216
6319
|
ValidationService.registerValidator(lessThanValidator);
|
|
6217
|
-
ValidationService.registerValidator(minLengthValidator);
|
|
6218
6320
|
ValidationService.registerValidator(matchesValidator);
|
|
6321
|
+
ValidationService.registerValidator(maxDateValidator);
|
|
6219
6322
|
ValidationService.registerValidator(maxLengthValidator);
|
|
6220
|
-
ValidationService.registerValidator(minValueValidator);
|
|
6221
6323
|
ValidationService.registerValidator(maxValueValidator);
|
|
6222
6324
|
ValidationService.registerValidator(minDateValidator);
|
|
6223
|
-
ValidationService.registerValidator(
|
|
6325
|
+
ValidationService.registerValidator(minLengthValidator);
|
|
6326
|
+
ValidationService.registerValidator(minValueValidator);
|
|
6224
6327
|
ValidationService.registerValidator(numberValidator);
|
|
6225
|
-
ValidationService.registerValidator(currencyValidator);
|
|
6226
6328
|
ValidationService.registerValidator(organisationsnummerValidator);
|
|
6227
6329
|
ValidationService.registerValidator(percentValidator);
|
|
6228
6330
|
ValidationService.registerValidator(personnummerFormatValidator);
|
|
6229
6331
|
ValidationService.registerValidator(personnummerLuhnValidator);
|
|
6332
|
+
ValidationService.registerValidator(personnummerNotSame);
|
|
6333
|
+
ValidationService.registerValidator(personnummerOlder);
|
|
6334
|
+
ValidationService.registerValidator(personnummerYounger);
|
|
6230
6335
|
ValidationService.registerValidator(phoneNumberValidator);
|
|
6231
6336
|
ValidationService.registerValidator(plusgiroValidator);
|
|
6232
6337
|
ValidationService.registerValidator(postalCodeValidator);
|