Skip to content

Commit

Permalink
Console-UI Add validation for name field in create address space (EnM…
Browse files Browse the repository at this point in the history
  • Loading branch information
drcoolsanjeev authored Jun 18, 2020
1 parent c0e299f commit b9fe693
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { ConfiguringRoutes } from "./ConfiguringRoutes";
import { EndpointConfiguration } from "modules/address-space/components";
import { IAddressSpaceSchema } from "schema/ResponseTypes";
import { useQuery } from "@apollo/react-hooks";

export interface IRouteConf {
protocol: string;
hostname?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "graphql-module/queries";
import { Loading } from "use-patternfly";
import { IAddressSpaceSchema } from "schema/ResponseTypes";
import { dnsSubDomainRfc1123NameRegexp } from "utils";

export interface IMessagingProjectConfigurationProps {
projectDetail: IMessagingProject;
Expand Down Expand Up @@ -90,7 +91,11 @@ const MessagingProjectConfiguration: React.FunctionComponent<IMessagingProjectCo
setProjectDetail({ ...projectDetail, namespace: value });
};
const handleNameChange = (value: string) => {
setProjectDetail({ ...projectDetail, name: value });
setProjectDetail({
...projectDetail,
isNameValid: dnsSubDomainRfc1123NameRegexp.test(value),
name: value
});
};
const handleTypeChange = (_: boolean, event: any) => {
setProjectDetail({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
RETURN_ADDRESS_SPACE_DETAIL
} from "graphql-module/queries";
import { IDropdownOption } from "components";
import { messagingAddressNameRegexp } from "utils";
import { dnsSubDomainRfc1123NameRegexp } from "utils";
import { useStoreContext, types } from "context-state-reducer";
import { IAddressSpacesResponse } from "schema/ResponseTypes";
import { FetchPolicy } from "constant";
Expand Down Expand Up @@ -76,7 +76,7 @@ export const CreateAddress: React.FunctionComponent = () => {

const handleAddressChange = (name: string) => {
setAddressName(name);
!messagingAddressNameRegexp.test(name)
!dnsSubDomainRfc1123NameRegexp.test(name)
? setIsNameValid(false)
: setIsNameValid(true);
};
Expand Down

0 comments on commit b9fe693

Please sign in to comment.