mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
custom fields (#744)
--------- Co-authored-by: Carlos Valente <carlosvalente@pm.me>
This commit is contained in:
committed by
GitHub
parent
1a420a1ddd
commit
c1377544a0
@@ -0,0 +1,17 @@
|
||||
import { isAlphanumeric } from './isAlphanumeric';
|
||||
|
||||
describe('test isAlphanumeric() function', () => {
|
||||
it('it OK strings', () => {
|
||||
const ts = ['abcdefghijklmnopqrstuvwxyz', '0123456798', '123asd'];
|
||||
for (const s of ts) {
|
||||
expect(isAlphanumeric(s)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('it bad strings', () => {
|
||||
const ts = ['!abcd1234', 'åøæ', '*'];
|
||||
for (const s of ts) {
|
||||
expect(isAlphanumeric(s)).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @description Validates a alphanumeric string
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export const isAlphanumeric = (text: string): boolean => {
|
||||
const regex = /^[a-z0-9]+$/i;
|
||||
return regex.test(text);
|
||||
};
|
||||
Reference in New Issue
Block a user