Skip to content

Commit

Permalink
global validation for export now includes start and end time validati…
Browse files Browse the repository at this point in the history
…on - MR
  • Loading branch information
marungo committed Mar 21, 2018
1 parent 629dd23 commit 004ed24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/components/timeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ export default class TimeRange extends React.Component {
<label> &nbsp; End Time: &nbsp;</label>
<input name="end" id="timeRange" type="text" placeholder="00:00.00" value={this.props.range[1]}
onChange={this.handleInputChange}/>

<span id="formatvalidFormatator" style={this.validateInput()}>
&nbsp; valid format is MM:SS.FF (with seconds between 0 and 59 and frames between 0 and {this.props.numFrames})
</span>
<span id="endAndStartValidator" style={this.validateEndAndStart()}>
&nbsp; end time stamp must be after or equal to the start time
&nbsp; end timestamp must be after (or equal to) start timestamp
</span>

</div>
);
}
Expand Down
13 changes: 10 additions & 3 deletions app/utilities/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const endIsLaterThanStart = (range) => {
return (startMins === endMins
? (startSeconds === endSeconds
? (startFrames === endFrames
? true // if they're the same, then return true
? true
: endFrames > startFrames)
: endSeconds > startSeconds)
: endMins > startMins);
Expand All @@ -43,8 +43,15 @@ export const validateAllInputs = (state, numFrames) => {
let traverser = (obj) => {
if (typeof obj == "object") {
Object.entries(obj).forEach(([key, value]) => {
if ((key === "start" || key === "end") && !isValid(value, numFrames)) {
valid = false;
if (key === "start") {
const startTime = obj.start;
const endTime = obj.end;

if (!isValid(startTime, numFrames)
|| !isValid(endTime, numFrames)
|| !endIsLaterThanStart([startTime, endTime])) {
valid = false;
}
}
traverser(value);
});
Expand Down

0 comments on commit 004ed24

Please sign in to comment.