Skip to content

Commit d2125ab

Browse files
authored
Merge pull request #762 from materialsproject/alphaID-validation
alphaID validation
2 parents 823bbbd + 453ccdc commit d2125ab

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

  • src/components/data-entry/MaterialsInput

src/components/data-entry/MaterialsInput/utils.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,7 @@ export const validateSmiles = (value: string): string | null => {
334334
* @returns Validated id string or null
335335
*/
336336
export const validateMPID = (value: string): string | null => {
337-
if (
338-
value.match(/mp\-\d/) !== null ||
339-
value.match(/mvc\-\d/) !== null ||
340-
value.match(/mol\-\d/) !== null
341-
) {
342-
return value;
343-
} else {
344-
return null;
345-
}
337+
return /^mp-([a-zA-Z]+|\d+)$/.test(value) || /^(mvc|mol)-\d+$/.test(value) ? value : null;
346338
};
347339

348340
/**

0 commit comments

Comments
 (0)