Browse Source

logs: Fixed validation on add log form:

1.0
Gisle Aune 6 years ago
parent
commit
3fbac994d2
  1. 10
      marko/page/logs/components/add-log-modal/component.js

10
marko/page/logs/components/add-log-modal/component.js

@ -40,6 +40,10 @@ module.exports = class {
} }
const input = Object.assign({}, this.state.values) const input = Object.assign({}, this.state.values)
if (input.date == "") {
this.state.error = "You need to specify a date (Did you mean "+moment().format("YYYY-MM-DD HH:mm:ss")+"?)"
return
}
input.date = new Date(input.date) input.date = new Date(input.date)
if (Number.isNaN(input.date)) { if (Number.isNaN(input.date)) {
@ -47,6 +51,12 @@ module.exports = class {
return return
} }
// They're not the same space!
if (input.channel.length < 2 || input.channel.includes(" ") || input.channel.includes(" ") || input.channel.charAt(0) !== "#") {
this.state.error = "Invalid channel name"
return
}
this.state.loading = true this.state.loading = true
logsApi.add(input).then(log => { logsApi.add(input).then(log => {
window.location = `/logs/${log.id}/` window.location = `/logs/${log.id}/`

Loading…
Cancel
Save