Skip to content

Commit

Permalink
Validate symbols and number in first charater of project name
Browse files Browse the repository at this point in the history
  • Loading branch information
royallsilwallz committed May 1, 2024
1 parent add0450 commit 4d338a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/projectCreate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ const ProjectCreate = () => {
setErr({ error: true, message: intl.formatMessage(messages.noProjectName) });
throw new Error('Missing project name.');
}
if (!/^[a-zA-Z]/.test(metadata.projectName)) {
setErr({ error: true, message: intl.formatMessage(messages.projectNameValidationError) });
throw new Error('Project name validation error.');
}
if (!metadata.geom) {
setErr({ error: true, message: intl.formatMessage(messages.noGeometry) });
throw new Error('Missing geom.');
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/projectCreate/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export default defineMessages({
id: 'management.projects.create.errors.no_project_name',
defaultMessage: 'Name is a required field.',
},
projectNameValidationError: {
id: 'management.projects.create.errors.project_name_validation_error',
defaultMessage: 'Project name should start with an alphabet.',
},
noGeometry: {
id: 'management.projects.create.errors.no_geometry',
defaultMessage: "You need to define the project's area of interest.",
Expand Down

0 comments on commit 4d338a8

Please sign in to comment.