Skip to content

Commit

Permalink
Merge pull request #967 from glific/feature/shortcode-validation
Browse files Browse the repository at this point in the history
Shortcode validation added
  • Loading branch information
DigneshGujarathi authored Feb 1, 2021
2 parents 340fb61 + 08f5307 commit 6f1b5dd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/containers/Template/Form/Template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ import { CREATE_MEDIA_MESSAGE } from '../../../graphql/mutations/Chat';
import { Checkbox } from '../../../components/UI/Form/Checkbox/Checkbox';
import { USER_LANGUAGES } from '../../../graphql/queries/Organization';

const regexForShortcode = /^[a-z0-9_]+$/g;

const HSMValidation = {
example: Yup.string()
.transform((current, original) => {
return original.getCurrentContent().getPlainText();
})
.required('Example is required.'),
category: Yup.object().nullable().required('Category is required.'),
shortcode: Yup.string().required('Element name is required.'),
shortcode: Yup.string()
.required('Element name is required.')
.matches(
regexForShortcode,
'Only lowercase alphanumeric characters and underscores are allowed.'
),
};

const dialogMessage = ' It will stop showing when you are drafting a customized message.';
Expand Down

0 comments on commit 6f1b5dd

Please sign in to comment.