diff --git a/src/components/Entity.js b/src/components/Entity.js
index d0f511b..cfca27d 100644
--- a/src/components/Entity.js
+++ b/src/components/Entity.js
@@ -2,7 +2,7 @@ import React from 'react';
import "./Form.css";
-const Entity = ({label, required, children}) => {
+const Entity = ({label, validated, required, children}) => {
function getAsterisk() {
if (required) {
@@ -12,7 +12,7 @@ const Entity = ({label, required, children}) => {
}
}
- function getNotification() {
+ function getNotificationMessage() {
if (required) {
return "필수 질문입니다.";
} else {
@@ -20,6 +20,10 @@ const Entity = ({label, required, children}) => {
}
}
+ let notificationMessageWillBeRendered = " ";
+ if (!validated) {
+ notificationMessageWillBeRendered = getNotificationMessage();
+ }
return (
@@ -29,9 +33,8 @@ const Entity = ({label, required, children}) => {
{children}
-
- {getNotification()}
+ {notificationMessageWillBeRendered}
diff --git a/src/components/Form.js b/src/components/Form.js
index 20cf97f..e0c5583 100644
--- a/src/components/Form.js
+++ b/src/components/Form.js
@@ -5,6 +5,7 @@ import Entity from "./Entity";
import LinkedText from "./LinkedText";
import "./Form.css";
import { RESTAPI_HOST } from "../consts/config";
+import {isValid, notEmptyString} from "../utils/ValidationUtils";
const libraryName = "libraryName";
@@ -27,6 +28,19 @@ const otherFacilities = "otherFacilities";
class Form extends Component {
+ validator = {
+ [libraryName]: [notEmptyString],
+ [libraryLocation]: [notEmptyString],
+ [managerName]: [notEmptyString],
+ [managerEmail]: [notEmptyString],
+ [managerPhonenumber]: [notEmptyString],
+ [capacityOfAudiences]: [notEmptyString],
+ // [facilities]: [],
+ // [requirementsForSpeaker]: [],
+ // [personalInfoAgreement]: [],
+ [noVolunteerAgreement]: [],
+ [otherFacilities]: [],
+ };
state = {
[libraryName]: null,
@@ -120,6 +134,7 @@ class Form extends Component {
{
+ return validator(data);
+ });
+
+ const everycasesAreValid = isValidOnEach.reduce(
+ (isValidOnEach1, isValidOnEach2) => (isValidOnEach1 && isValidOnEach2)
+ , true);
+
+ return everycasesAreValid;
+}
\ No newline at end of file