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

Added validation for keyword #937

Merged
merged 1 commit into from
Jan 23, 2021
Merged
Changes from all 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
5 changes: 4 additions & 1 deletion src/containers/Flow/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ export interface FlowProps {
match: any;
}

const regex = /^[a-z]+(,[a-z]+)*$/g;

const FormSchema = Yup.object().shape({
name: Yup.string().required('Name is required.'),
keywords: Yup.string().matches(regex, 'Only lowercase are allowed.'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
keywords: Yup.string().matches(regex, 'Only lowercase are allowed.'),
keywords: Yup.string().matches(regex, 'Only lowercase are allowed.'),

Can we have a generic error message as currently if we press space then also we get the same error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space is also not a valid input for this, it only allows comma separated lowercase keywords. We also have helper text for this.

});

const dialogMessage = "You won't be able to use this flow again.";
Expand Down Expand Up @@ -58,7 +61,7 @@ export const Flow: React.SFC<FlowProps> = ({ match }) => {
}
setName(fieldName);

// we are recieving keywords as an array object
// we are receiving keywords as an array object
if (fieldKeywords.length > 0) {
// lets display it comma separated
setKeywords(fieldKeywords.join(','));
Expand Down