Skip to content

Commit a889eba

Browse files
committed
fix data validation to only works with number data
1 parent 350c3df commit a889eba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/cli/single-feature.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ export default async function singleFeatureProcess(data) {
3737
])
3838

3939
if (answers.feature == answers.label) {
40-
print(chalk.bgMagenta('Feature and label can not be same'))
40+
print(chalk.redBright('\n[!] Feature and label can not be same'))
4141

4242
if (await confirm({ message: 'Back?'})) return;
4343
}
4444

4545

46+
const numberPattern = /^[+-]?\d+(\.\d+)?$/
4647
for (const item of data) {
47-
if (!Number.isNaN(item[answers.feature]) || !Number.isNaN(item[answers.label])) {
48+
if (!numberPattern.test(item[answers.feature]) || !numberPattern.test(item[answers.label])) {
4849
print(chalk.redBright('\n[!] Some data is not a number! Unable to process further!'))
4950
await confirm({ message: 'Continue?'})
5051
return;

0 commit comments

Comments
 (0)