Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/6373 project name input validation #84

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frontend/src/components/projectCreate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ const ProjectCreate = () => {

const handleCreate = useCallback(
(cloneProjectData) => {
if (!metadata.projectName.trim()) {
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
8 changes: 8 additions & 0 deletions frontend/src/components/projectCreate/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ export default defineMessages({
id: 'management.projects.create.errors.closed_linestring',
defaultMessage: 'Points do not form a closed linestring',
},
noProjectName: {
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
Loading