Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating startDate vs endDate #50

Open
verscph opened this issue Jan 27, 2019 · 0 comments
Open

Validating startDate vs endDate #50

verscph opened this issue Jan 27, 2019 · 0 comments

Comments

@verscph
Copy link

verscph commented Jan 27, 2019

I needed to validate whether the startDate is before the endDate and whether both dates have the right format:

var dateSchema = new schema({
dateRange: {
    type: {
      startDate: {
        type: Date,
        required: true,
        validate: [dateFormatValidator, '{VALUE} is not a valid date!']
      },
      endDate: {
        type: Date,
        required: true,
        validate: [dateFormatValidator, '{VALUE} is not a valid date!']
      }
    },
    required: true,
    validate: [dateRangeValidator, 'startDate must be before endDate!']
  }
});

The validation of dateRange is executed, but the validation of the startDate and endDate format isn't. Is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant