Skip to content

Commit

Permalink
feat(): add create form error validation for site and project entities (
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinPerry authored Nov 4, 2024
1 parent eebf07f commit 43dab51
Show file tree
Hide file tree
Showing 44 changed files with 286 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/common/src/core/schemas/shared/subschemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export const ENTITY_NAME_SCHEMA = {
type: "string",
minLength: 1,
maxLength: 250,
format: "entityTitleValidator",
};

export const SITE_ENTITY_NAME_SCHEMA = {
type: "string",
minLength: 1,
maxLength: 250,
format: "siteEntityTitleValidator",
};

export const ENTITY_SUMMARY_SCHEMA = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `shared.fields.title.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `shared.fields.title.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/groups/_internal/GroupUiSchemaCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/groups/_internal/GroupUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `shared.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/pages/_internal/PageUiSchemaCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/pages/_internal/PageUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/projects/_internal/ProjectUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/sites/_internal/SiteSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IAsyncConfigurationSchema } from "../../core";
import {
ENTITY_IS_DISCUSSABLE_SCHEMA,
PRIVACY_CONFIG_SCHEMA,
SITE_ENTITY_NAME_SCHEMA,
} from "../../core/schemas/shared";
import { HubItemEntitySchema } from "../../core/schemas/shared/HubItemEntitySchema";

Expand All @@ -23,6 +24,7 @@ export const getSiteSchema = (siteId: string) =>
...HubItemEntitySchema,
properties: {
...HubItemEntitySchema.properties,
name: SITE_ENTITY_NAME_SCHEMA,
_discussions: ENTITY_IS_DISCUSSABLE_SCHEMA,
telemetry: PRIVACY_CONFIG_SCHEMA,
_urlInfo: {
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/sites/_internal/SiteUiSchemaCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.siteEntityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/sites/_internal/SiteUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.siteEntityTitleValidatorError`,
},
],
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/surveys/_internal/SurveyUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `shared.fields.title.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export const buildUiSchema = async (
icon: true,
labelKey: `${i18nScope}.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `${i18nScope}.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ describe("buildUiSchema: discussion create", () => {
icon: true,
labelKey: `shared.fields.title.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ describe("buildUiSchema: discussion edit", () => {
icon: true,
labelKey: "shared.fields.title.maxLengthError",
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down Expand Up @@ -307,6 +313,12 @@ describe("buildUiSchema: discussion edit", () => {
icon: true,
labelKey: "shared.fields.title.maxLengthError",
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ describe("GroupUiSchemaCreate", () => {
icon: true,
labelKey: `some.scope.fields.name.maxLengthError`,
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ describe("GroupUiSchemaCreateAssociation", () => {
icon: true,
labelKey: "some.scope.fields.name.maxLengthError",
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ describe("GroupUiSchemaCreateEdit", () => {
icon: true,
labelKey: "some.scope.fields.name.maxLengthError",
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ describe("GroupUiSchemaCreateFollowers", () => {
icon: true,
labelKey: "some.scope.fields.name.maxLengthError",
},
{
type: "ERROR",
keyword: "format",
icon: true,
labelKey: `some.scope.fields.name.entityTitleValidatorError`,
},
],
},
},
Expand Down
Loading

0 comments on commit 43dab51

Please sign in to comment.