bfg-common 1.3.535 → 1.3.536

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.
@@ -42,24 +42,27 @@ export const checkValidityName = async (
42
42
  return { valid: true, msg: null }
43
43
  }
44
44
 
45
- export const generateDataId = (errorMessage: string): string => {
45
+ export const validateNameAndGenerateDataId = (name: string, _errorMessage: string): string => {
46
46
  let baseDataId = 'storage-name-alert-error'
47
47
 
48
48
  const patterns = [
49
49
  {
50
- regex:
50
+ regex: /^[a-zA-Z0-9_\-\.]+$/,
51
+ error_message:
51
52
  /invalid name, must only contain letters, numbers, and '_', '-' '.' symbols/,
52
53
  suffix: '-invalid-name-symbols',
53
54
  },
54
55
  {
55
- regex: /invalid name length, must be between: \d+ and \d+ characters/,
56
+ regex: /^.{3,64}$/,
57
+ error_message:
58
+ /invalid name length, must be between: \d+ and \d+ characters/,
56
59
  suffix: '-invalid-name-length',
57
60
  },
58
61
  ]
59
62
 
60
63
  // Проверка error_message на соответствие шаблонам
61
64
  for (const pattern of patterns) {
62
- if (pattern.regex.test(errorMessage)) {
65
+ if (pattern.regex.test(name)) {
63
66
  return `${baseDataId}${pattern.suffix}`
64
67
  }
65
68
  }
@@ -41,7 +41,7 @@ import { UI_I_Localization } from '~/lib/models/interfaces'
41
41
  import { UI_I_FormValidationDataStore } from '~/components/common/wizards/datastore/add/sharedStorm/deviceSelection/lib/models/interfaces'
42
42
  import { defaultFormFunc } from '~/components/common/wizards/datastore/add/local/createName/lib/config/defaultForm'
43
43
  import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
44
- import { generateDataId } from '~/components/common/wizards/datastore/add/lib/utils'
44
+ import { validateNameAndGenerateDataId } from '~/components/common/wizards/datastore/add/lib/utils'
45
45
 
46
46
  const props = defineProps<{
47
47
  localCreateNameSubmit: number
@@ -87,7 +87,10 @@ const errorAlertDataId = ref<string>('')
87
87
  const errors = ref<string[]>([])
88
88
  const showValidationErrors = (data: string[]): void => {
89
89
  errors.value = data
90
- errorAlertDataId.value = generateDataId(data[0])
90
+ errorAlertDataId.value = validateNameAndGenerateDataId(
91
+ form.value.name.value,
92
+ data[0]
93
+ )
91
94
  }
92
95
  const onRemoveValidationErrors = (): void => {
93
96
  errors.value = []
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.535",
4
+ "version": "1.3.536",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",