Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#3202] improve(web): modified rules for create name field (#3507)

CHEYNE3a1458b77e43
diff --git a/web/src/app/metalakes/CreateMetalakeDialog.js b/web/src/app/metalakes/CreateMetalakeDialog.js
index 788c92c8da..d2e1ef690a 100644
--- a/web/src/app/metalakes/CreateMetalakeDialog.js
+++ b/web/src/app/metalakes/CreateMetalakeDialog.js
@@ -32,7 +32,7 @@ import { yupResolver } from '@hookform/resolvers/yup'
import { groupBy } from 'lodash-es'
import { genUpdates } from '@/lib/utils'
-import { nameRegex, keyRegex } from '@/lib/utils/regex'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
const defaultValues = {
name: '',
@@ -40,13 +40,7 @@ const defaultValues = {
}
const schema = yup.object().shape({
- name: yup
- .string()
- .required()
- .matches(
- nameRegex,
- 'This field must start with a letter or underscore, and can only contain letters, numbers, dashes, and underscores'
- )
+ name: yup.string().required().matches(nameRegex, nameRegexDesc)
})
const Transition = forwardRef(function Transition(props, ref) {
diff --git a/web/src/app/metalakes/metalake/rightContent/CreateCatalogDialog.js b/web/src/app/metalakes/metalake/rightContent/CreateCatalogDialog.js
index 2e9b1ab24c..fe6b7917ff 100644
--- a/web/src/app/metalakes/metalake/rightContent/CreateCatalogDialog.js
+++ b/web/src/app/metalakes/metalake/rightContent/CreateCatalogDialog.js
@@ -37,7 +37,7 @@ import { yupResolver } from '@hookform/resolvers/yup'
import { groupBy } from 'lodash-es'
import { genUpdates } from '@/lib/utils'
import { providers, filesetProviders, messagingProviders } from '@/lib/utils/initial'
-import { nameRegex, keyRegex } from '@/lib/utils/regex'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
import { useSearchParams } from 'next/navigation'
const defaultValues = {
@@ -49,13 +49,7 @@ const defaultValues = {
}
const schema = yup.object().shape({
- name: yup
- .string()
- .required()
- .matches(
- nameRegex,
- 'This field must start with a letter or underscore, and can only contain letters, numbers, dashes, and underscores'
- ),
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
type: yup.mixed().oneOf(['relational', 'fileset', 'messaging']).required(),
provider: yup.string().when('type', (type, schema) => {
switch (type) {
diff --git a/web/src/lib/utils/regex.js b/web/src/lib/utils/regex.js
index 7f8c039a07..f0776b0697 100644
--- a/web/src/lib/utils/regex.js
+++ b/web/src/lib/utils/regex.js
@@ -3,6 +3,9 @@
* This software is licensed under the Apache License version 2.
*/
-export const nameRegex = /^[a-zA-Z_-][a-zA-Z0-9_-]*$/
+export const nameRegex = /^\w[\w]{0,63}$/
+
+export const nameRegexDesc =
+ 'This field must begin with a letter or underscore, contain only alphanumeric characters or underscores, and be between 1 and 64 characters in length'
export const keyRegex = /^[a-zA-Z_][a-zA-Z0-9-_.]*$/