Skip to content

Validating startDate vs endDate #50

Open
@verscph

Description

@verscph

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions