Skip to content

Commit

Permalink
swap order of validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Apr 2, 2020
1 parent e458826 commit 9efcdf7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/validators/date-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const DateFormat = BaseValidator.extend({

validate(value, options) {
switch (true) {
case value.startsWith('-'):
return /-\d{4}/.test(value) ? true : 'Please enter a valid date';
case (!value && options.allowBlank):
return true;
case value.startsWith('-'):
return /-\d{4}/.test(value) ? true : 'Please enter a valid date';
default:
try {
let status = edtf.parse(value, { types: [ 'Date', 'Year', 'Decade', 'Century', 'Season', 'Interval' ] });
Expand Down

0 comments on commit 9efcdf7

Please sign in to comment.