-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #826 from hotosm/feat-projectinfo-bug
Feat projectinfo bug
- Loading branch information
Showing
5 changed files
with
67 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 52 additions & 54 deletions
106
src/frontend/main/src/components/editproject/validation/EditProjectDetailsValidation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,56 @@ | ||
|
||
interface ProjectValues { | ||
organization: string; | ||
name: string; | ||
username: string; | ||
id: string; | ||
short_description: string; | ||
description: string; | ||
// odk_central_url: string; | ||
// odk_central_user: string; | ||
// odk_central_password: string; | ||
organization: string; | ||
name: string; | ||
username: string; | ||
id: string; | ||
short_description: string; | ||
description: string; | ||
// odk_central_url: string; | ||
// odk_central_user: string; | ||
// odk_central_password: string; | ||
} | ||
interface ValidationErrors { | ||
organization?: string; | ||
name?: string; | ||
username?: string; | ||
id?: string; | ||
short_description?: string; | ||
description?: string; | ||
// odk_central_url?: string; | ||
// odk_central_user?: string; | ||
// odk_central_password?: string; | ||
} | ||
const regexForSymbol = /_/g; | ||
|
||
function EditProjectValidation(values: ProjectValues) { | ||
const errors: ValidationErrors = {}; | ||
|
||
// if (!values?.organization) { | ||
// errors.organization = 'Organization is Required.'; | ||
// } | ||
// if (!values?.odk_central_url) { | ||
// errors.odk_central_url = 'ODK Central Url is Required.'; | ||
// } | ||
// if (!values?.odk_central_user) { | ||
// errors.odk_central_user = 'ODK Central User is Required.'; | ||
// } | ||
// if (!values?.odk_central_password) { | ||
// errors.odk_central_password = 'ODK Central Password is Required.'; | ||
// } | ||
if (!values?.name) { | ||
errors.name = 'Project Name is Required.'; | ||
} | ||
interface ValidationErrors { | ||
organization?: string; | ||
name?: string; | ||
username?: string; | ||
id?: string; | ||
short_description?: string; | ||
description?: string; | ||
// odk_central_url?: string; | ||
// odk_central_user?: string; | ||
// odk_central_password?: string; | ||
if (values?.name && regexForSymbol.test(values.name)) { | ||
errors.name = 'Project Name should not contain _.'; | ||
} | ||
const regexForSymbol = /[-_]/g; | ||
|
||
function EditProjectValidation(values: ProjectValues) { | ||
const errors: ValidationErrors = {}; | ||
|
||
// if (!values?.organization) { | ||
// errors.organization = 'Organization is Required.'; | ||
// } | ||
// if (!values?.odk_central_url) { | ||
// errors.odk_central_url = 'ODK Central Url is Required.'; | ||
// } | ||
// if (!values?.odk_central_user) { | ||
// errors.odk_central_user = 'ODK Central User is Required.'; | ||
// } | ||
// if (!values?.odk_central_password) { | ||
// errors.odk_central_password = 'ODK Central Password is Required.'; | ||
// } | ||
if (!values?.name) { | ||
errors.name = 'Project Name is Required.'; | ||
} | ||
if (values?.name && regexForSymbol.test(values.name)) { | ||
errors.name = 'Project Name should not contain symbols.'; | ||
} | ||
if (!values?.short_description) { | ||
errors.short_description = 'Short Description is Required.'; | ||
} | ||
if (!values?.description) { | ||
errors.description = 'Description is Required.'; | ||
} | ||
|
||
return errors; | ||
if (!values?.short_description) { | ||
errors.short_description = 'Short Description is Required.'; | ||
} | ||
|
||
export default EditProjectValidation; | ||
|
||
if (!values?.description) { | ||
errors.description = 'Description is Required.'; | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
export default EditProjectValidation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters