@ -7,6 +7,16 @@ describe('validateMetadataName', () => {
|
|||||||
|
|
||||||
expect(validateMetadataName(input)).not.toThrow;
|
expect(validateMetadataName(input)).not.toThrow;
|
||||||
});
|
});
|
||||||
|
it('throws error if string has spaces', () => {
|
||||||
|
const input = 'name with spaces';
|
||||||
|
|
||||||
|
expect(() => validateMetadataName(input)).toThrow(InvalidStringException);
|
||||||
|
});
|
||||||
|
it('throws error if string starts with capital letter', () => {
|
||||||
|
const input = 'StringStartingWithCapitalLetter';
|
||||||
|
|
||||||
|
expect(() => validateMetadataName(input)).toThrow(InvalidStringException);
|
||||||
|
});
|
||||||
|
|
||||||
it('throws error if string has non latin characters', () => {
|
it('throws error if string has non latin characters', () => {
|
||||||
const input = 'בְרִבְרִ';
|
const input = 'בְרִבְרִ';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { InvalidStringException } from 'src/engine/metadata-modules/errors/InvalidStringException';
|
import { InvalidStringException } from 'src/engine/metadata-modules/errors/InvalidStringException';
|
||||||
|
|
||||||
const VALID_STRING_PATTERN = /^[a-zA-Z][a-zA-Z0-9 ]*$/;
|
const VALID_STRING_PATTERN = /^[a-z][a-zA-Z0-9]*$/;
|
||||||
|
|
||||||
export const validateMetadataName = (string: string) => {
|
export const validateMetadataName = (string: string) => {
|
||||||
if (!string.match(VALID_STRING_PATTERN)) {
|
if (!string.match(VALID_STRING_PATTERN)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user