Skip to content

Commit

Permalink
added validations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed Jun 16, 2022
1 parent 9c2a0d4 commit 140526a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RouterFormProps } from 'components/flow/props';
import TypeList from 'components/nodeeditor/TypeList';
import * as React from 'react';
import { FormEntry, FormState, StringEntry } from 'store/nodeEditor';
import { Numeric, Required, validate } from 'store/validators';
import { Numeric, Required, shouldRequireIf, validate } from 'store/validators';

import { nodeToState, stateToNode } from './helpers';
import styles from './ContactProfileRouterForm.module.scss';
Expand Down Expand Up @@ -54,6 +54,13 @@ export default class ContactProfileRouterForm extends React.Component<
private handleSave(): void {
let valid = true;

const validName = validate('Name', this.state.profileName.value, [shouldRequireIf(true)]);

if (validName.validationFailures.length > 0) {
valid = false;
}
this.setState({ profileName: validName });

if (valid) {
this.props.updateRouter(stateToNode(this.props.nodeSettings, this.state));
this.props.onClose(false);
Expand Down

0 comments on commit 140526a

Please sign in to comment.