text: const mongoose = require('mongoose');
  const validator = require('validator');
  
  const assignmentSchema = new mongoose.Schema({
    name: {
      type: String,
      required: true,
      trim: true,
    },
    links: [
      {
        link: {
          type: String,
          required: false,
          trim: true,
          validate(value) {
            if (!validator.isDataURI(value)) {
              throw new Error('invalid URI');
            }
          },
        },
        name: {
          type: String,
          required: false,
          trim: true,
        },
      },
    ],
    students: [
      {
        student: {
          type: String,
          required: true,
        },
      },
    ],
    publisher: {
      type: String,
      required: true,
    },
    classId: {
      type: String,
      required: true,
    },
    date: {
      type: Date,
      required: true,
    },
    files: [
      {
        file: {
          type: String,
          required: false,
          validate(value) {
            if (!validator.isDataURI(value)) {
              throw new Error('invalid URL for file');
            }
          },
        },
        name: {
          type: String,
          required: false,
          trim: false,
        },
      },
    ],
    richContent: {
      type: String,
      required: false,
    },
    chatEnabled: {
      type: Boolean,
      required: true,
    },
    rubrics: [
      {
        rubric: {
          type: String,
          required: false,
          validate(value) {
            if (!validator.isDataURI(value)) {
              throw new Error('Invalid file URL');
            }
          },
        },
      },
    ],
    dueDate: {
      type: Date,
      required: false,
    },
  });
  
  const Assignment = mongoose.model('Assignment', assignmentSchema);
  
  module.exports = Assignment;
  