Skip to content
Open
Changes from 2 commits
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
17 changes: 15 additions & 2 deletions wpilib-utility-standalone/src/validators.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
export function hasSpecialCharacter(str: string): boolean {
for(let c of str) {
// check number character
if( c >= '0' && c <= '9') continue;
// check upper character
if( c >= 'A' && c <= 'Z') continue;
// check lower character
if( c <= 'a' && c <= 'z') continue;

return true;
}
return false;
}

export function validateProject(input: HTMLInputElement, div: HTMLDivElement) {
const s = input.value;
const match = s.match(/\w[\w-]*$/gm);
if (match === null || match.length === 0) {
if (hasSpecialCharacter(s)) {
div.innerText = 'Invalid Project Name';
div.classList.add('error');
input.classList.add('error');
Expand Down