A Directus extension that validates that a second date field is greater than a first date field. This is particularly useful for scenarios like validating departure and arrival dates, start and end dates, etc.
- Validates that the second date is greater than the first date
- Works with both create and update operations
- Configurable collection and field names
- Customizable error messages
- Handles partial updates by fetching missing dates from the database
- Install the extension:
git clone https://github.com/yourusername/directus-extension-validate-two-dates.git
cd directus-extension-validate-two-dates- Install dependencies:
npm install- Configure the extension by editing
src/config.js:
export const collection = "your_collection"; // The collection to validate
export const firstDateField = "start_date"; // First date field name
export const secondDateField = "end_date"; // Second date field name
export const errorMessage = '"End Date" must be greater than "Start Date"'; // Custom error message- Build the extension:
npm run buildOnce installed and configured, the extension will automatically validate dates when:
- Creating new items
- Updating existing items
The validation ensures that the second date is always greater than the first date.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.