From b6a8df6d3eceaf22a0232c333e760f41fd7d3599 Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Wed, 1 Nov 2023 09:44:29 +0530 Subject: [PATCH 1/4] Update role name field input validation --- .../src/features/roles/components/edit-role/edit-role-basic.tsx | 2 +- .../features/roles/components/wizard-updated/role-basics.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx b/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx index 2655f732762..96e36fa3db5 100644 --- a/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx +++ b/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx @@ -167,7 +167,7 @@ export const BasicRoleDetails: FunctionComponent = (props: Basic = (props: RoleBasicPr > Date: Wed, 1 Nov 2023 09:51:31 +0530 Subject: [PATCH 2/4] Add changeset --- .changeset/little-pens-exist.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/little-pens-exist.md diff --git a/.changeset/little-pens-exist.md b/.changeset/little-pens-exist.md new file mode 100644 index 00000000000..76c972f647e --- /dev/null +++ b/.changeset/little-pens-exist.md @@ -0,0 +1,5 @@ +--- +"@wso2is/console": patch +--- + +Update role name field input validation From a3c3d4219acbbeb5df816acf82fb839f177a1877 Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Wed, 1 Nov 2023 12:00:48 +0530 Subject: [PATCH 3/4] Add rolename as input type for form field --- .../components/edit-role/edit-role-basic.tsx | 2 +- .../components/wizard-updated/role-basics.tsx | 2 +- modules/form/src/components/field-input.tsx | 5 +++-- modules/form/src/utils/validate.ts | 8 ++++++- modules/validation/src/index.ts | 4 +++- modules/validation/src/validation.ts | 22 ++++++++++++++++++- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx b/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx index 96e36fa3db5..403460ec9f0 100644 --- a/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx +++ b/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx @@ -167,7 +167,7 @@ export const BasicRoleDetails: FunctionComponent = (props: Basic = (props: RoleBasicPr > { return false; } }; + +/** + * This validates the role name. Returns true if valid. False if not valid. + * + * @param value - Input to be validated. + * @returns whether input is accepted or not. + */ +export const isValidRoleName = (value: string): boolean => { + try { + const result: ValidationResult = Joi.string() + .regex(new RegExp("^[a-zA-Z][a-zA-Z0-9-_. ]+$")) + .min(3) + .max(255) + .validate(value); + + return !result.error; + } catch (error) { + return false; + } +}; From 9beb9abf218f2ffd24b75ac8b6392df8c5e5a69a Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Wed, 1 Nov 2023 12:02:59 +0530 Subject: [PATCH 4/4] Update changeset --- .changeset/little-pens-exist.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/little-pens-exist.md b/.changeset/little-pens-exist.md index 76c972f647e..37ef2047c7c 100644 --- a/.changeset/little-pens-exist.md +++ b/.changeset/little-pens-exist.md @@ -1,5 +1,7 @@ --- "@wso2is/console": patch +"@wso2is/form": patch +"@wso2is/validation": patch --- Update role name field input validation