Skip to content

Commit 9e0713a

Browse files
author
Dustyn Blackmore
committed
Initial Validation State
Now uses the validation prop, if supplied, to determine default state.
1 parent 1d8e545 commit 9e0713a

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/components/Input.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ class Input extends Component {
159159
ourCallbackResult = false;
160160
break;
161161
}
162+
163+
// Handles initial validation state (Triggered for error message)
164+
if (this.props.validation) {
165+
this.handleHasValidation();
166+
}
167+
162168
if (ourCallbackResult !== "") {
163169
this.setState({
164170
onComponentDidMountCallback: ourCallbackResult
@@ -393,10 +399,16 @@ class Input extends Component {
393399

394400
handleHasValidation(event) {
395401
let value = undefined;
396-
switch (this.props.type) {
397-
default:
398-
value = event.target.value;
399-
break;
402+
403+
// Handles initial validation state, which does not include an event.
404+
if (event) {
405+
switch (this.props.type) {
406+
default:
407+
value = event.target.value;
408+
break;
409+
}
410+
} else {
411+
value = this.state.value;
400412
}
401413
let validationResult = undefined;
402414

0 commit comments

Comments
 (0)