@amimpact/willy-utils 4.8.1 → 4.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amimpact/willy-utils",
3
- "version": "4.8.1",
3
+ "version": "4.9.0",
4
4
  "description": "Javascript utils",
5
5
  "scripts": {
6
6
  "publish:prerelease": "npm version prerelease --preid beta && npm publish --tag beta",
package/src/date.ts CHANGED
@@ -26,7 +26,7 @@ const availableLocales = {
26
26
  */
27
27
  const getLocaleOptions = (localeString: string) => {
28
28
  // Alleen locales met daadwerkelijk een locale meegeven
29
- if (availableLocales?.[localeString]?.length) {
29
+ if (availableLocales?.[localeString]?.code?.length) {
30
30
  return {
31
31
  locale: availableLocales[localeString],
32
32
  };
package/src/index.ts CHANGED
@@ -24,7 +24,14 @@ import {
24
24
  wrap,
25
25
  } from './misc';
26
26
  import { $, $$, getParents } from './selectors';
27
- import { isCraftActionUrl, isInternalLink, isExternalUrl, isAsset, slugify } from './url';
27
+ import {
28
+ isCraftActionUrl,
29
+ isInternalLink,
30
+ isExternalUrl,
31
+ isAsset,
32
+ slugify,
33
+ isValidEmail,
34
+ } from './url';
28
35
 
29
36
  export {
30
37
  $,
@@ -53,6 +60,7 @@ export {
53
60
  isPlainObject,
54
61
  isTouchDevice,
55
62
  isValidUrl,
63
+ isValidEmail,
56
64
  observeResize,
57
65
  parseISODuration,
58
66
  readCookie,
package/src/url.ts CHANGED
@@ -139,3 +139,13 @@ export const slugify = (str: string) => {
139
139
  .replace(/[\s_-]+/g, '-')
140
140
  .replace(/^-+|-+$/g, '');
141
141
  };
142
+
143
+ /**
144
+ * Check op geldig email adres
145
+ * @param {string} email
146
+ */
147
+ export const isValidEmail = (email: string) => {
148
+ // Reguliere expressie voor een eenvoudig e-mailformaat
149
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
150
+ return emailRegex.test(email);
151
+ };