UNPKG

pl4y-data-library

Version:

This library contains the dtos, enums, schemas, and other data objects needed in the pl4y ecosystem.

48 lines (45 loc) 1.3 kB
import { Schema } from "mongoose"; export interface VendorDocument { businessName: string; email?: string; phone?: string; products?: string[]; updatedAt?: Date; businessType?: string; website?: string; rating?: number; } export const VendorSchema = new Schema<VendorDocument>( { businessName: { type: String, required: [true, "Business name is required"], minlength: [3, "Business name must be at least 3 characters long"], maxlength: [100, "Business name must not exceed 100 characters"], }, email: { type: String, match: [/^\S+@\S+\.\S+$/, "Email must be a valid email address"], }, phone: { type: String, match: [/^\d{10,15}$/, "Phone number must be between 10 and 15 digits"], }, products: { type: [String], }, website: { type: String, match: [/^https?:\/\/[^\s/$.?#].[^\s]*$/, "Website must be a valid URL"], }, rating: { type: Number, min: [1, "Rating must be at least 1"], max: [5, "Rating must not exceed 5"], }, }, { timestamps: true, collection: "vendors", }, );