@fabriktor/fx 0.0.168 → 0.0.170

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.
@@ -3,5 +3,8 @@ export type UsernameFormatResult = {
3
3
  normalized: string;
4
4
  error: string;
5
5
  };
6
+ export declare const usernameMinLength = 3;
7
+ export declare const usernameMaxLength = 40;
8
+ export declare const usernamePattern: RegExp;
6
9
  export declare function normalizeUsername(v: string): string;
7
10
  export declare function validateUsernameFormat(v: string): UsernameFormatResult;
@@ -3,14 +3,16 @@
3
3
  // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
4
  // not use this file except in compliance with the License. You may obtain
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- const usernameMinLength = 3;
7
- const usernameMaxLength = 40;
8
- const usernamePattern = /^[a-z][a-z0-9_]*$/;
6
+ export const usernameMinLength = 3;
7
+ export const usernameMaxLength = 40;
8
+ export const usernamePattern = /^[a-z][a-z0-9_]*$/;
9
9
  const usernameLetterPattern = /[a-z]/;
10
+ const usernameEndingPattern = /[a-z0-9]$/;
10
11
  const msgUsernameMinLength = "Username must contain at least 3 characters.";
11
12
  const msgUsernameMaxLength = "Username must contain at most 40 characters.";
12
13
  const msgUsernamePattern = "Username must start with a lowercase letter and contain only lowercase letters, digits, and underscores.";
13
14
  const msgUsernameLetter = "Username must contain at least one letter.";
15
+ const msgUsernameEnding = "Username must end with a letter or digit.";
14
16
  export function normalizeUsername(v) {
15
17
  return v.trim().toLowerCase();
16
18
  }
@@ -44,6 +46,13 @@ export function validateUsernameFormat(v) {
44
46
  error: msgUsernameLetter,
45
47
  };
46
48
  }
49
+ if (!usernameEndingPattern.test(normalized)) {
50
+ return {
51
+ valid: false,
52
+ normalized,
53
+ error: msgUsernameEnding,
54
+ };
55
+ }
47
56
  return {
48
57
  valid: true,
49
58
  normalized,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.168",
3
+ "version": "0.0.170",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {