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

function to validate a string is in C, S, V format #2263

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions src/lib/isCSV.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import assertString from './util/assertString';

export default function isCSV(str) {
assertString(str);
const regex = /^(\s*[\w\d\s-]+\s*,\s*)*[\w\d\s-]+\s*$/;
Fixed Show fixed Hide fixed
return regex.test(str);
}

Check failure on line 7 in src/lib/isCSV.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Newline required at end of file but not found

Check failure on line 7 in src/lib/isCSV.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Newline required at end of file but not found

Check failure on line 7 in src/lib/isCSV.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Newline required at end of file but not found

Check failure on line 7 in src/lib/isCSV.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Newline required at end of file but not found
Loading