Browse Source

Fixed validation of fictionalDate input in create/edit chapter modals.

master
Gisle Aune 6 years ago
parent
commit
3fc9d5de7f
  1. 8
      marko/page/story-content/components/create-chapter-modal/component.js
  2. 8
      marko/page/story-content/components/edit-chapter-modal/component.js

8
marko/page/story-content/components/create-chapter-modal/component.js

@ -53,8 +53,12 @@ module.exports = class {
let fictionalDate = new Date(values.fictionalDate + " UTC")
if (values.fictionalDate != "") {
if (Number.isNaN(fictionalDate)) {
this.state.error = `Could not parse ${values.fictionalDate} as date!`
if (Number.isNaN(fictionalDate.getTime())) {
this.state.error = `Could not parse ${values.fictionalDate} as date.`
if (values.fictionalDate.includes("th")) {
this.state.error += " Try to remove the 'th'."
}
return
}
} else {

8
marko/page/story-content/components/edit-chapter-modal/component.js

@ -49,8 +49,12 @@ module.exports = class {
let fictionalDate = new Date(values.fictionalDate + " UTC")
if (values.fictionalDate != "") {
if (Number.isNaN(fictionalDate)) {
this.state.error = `Could not parse ${values.fictionalDate} as date`
if (Number.isNaN(fictionalDate.getTime())) {
this.state.error = `Could not parse ${values.fictionalDate} as date.`
if (values.fictionalDate.includes("th")) {
this.state.error += " Try to remove the 'th'."
}
return
}
} else {

Loading…
Cancel
Save