-
Notifications
You must be signed in to change notification settings - Fork 6
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 #233 from zowe/bugfixes-installation-tab
Dataset Validation On Installation Stage
- Loading branch information
Showing
2 changed files
with
67 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
export const validateDatasetIterator = (schema: any) : { isValid: boolean, key: string } => { | ||
for (const key of Object.keys(schema)) { | ||
let value = schema[key]; | ||
if (typeof value === 'object' && value !== null) { | ||
const result = validateDatasetIterator(value); | ||
if(!result.isValid) { | ||
return {isValid: false, key: key}; | ||
} | ||
} else if(!isDatasetValid(value)) { | ||
return {isValid: false, key: key}; | ||
} | ||
} | ||
return {isValid: true, key: ''}; | ||
} | ||
|
||
export const isDatasetValid = (dsName: string) : boolean => { | ||
const DsNamePattern = "^[a-zA-Z#$@][a-zA-Z0-9#$@-]{0,7}([.][a-zA-Z#$@][a-zA-Z0-9#$@-]{0,7}){0,21}$"; | ||
const regEx = new RegExp(DsNamePattern); | ||
return regEx.test(dsName); | ||
} |