fix: minor fixes and add csv import support
This commit is contained in:
parent
289e7839c6
commit
fefbf15f5e
6 changed files with 73 additions and 32 deletions
|
|
@ -26,6 +26,20 @@ class AllowedString extends mongoose.SchemaType {
|
|||
}
|
||||
}
|
||||
|
||||
const email = {
|
||||
type: String,
|
||||
trim: true,
|
||||
lowercase: true,
|
||||
unique: true,
|
||||
validate: {
|
||||
validator: function(v) {
|
||||
return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v);
|
||||
},
|
||||
message: "Invalid email"
|
||||
},
|
||||
required: [true, "Email required"]
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
mongoose.Schema.Types['AllowedString'] = AllowedString
|
||||
|
||||
|
|
@ -61,7 +75,7 @@ const OrganizationVersion = {
|
|||
phone: { type: String },
|
||||
peoples: [{
|
||||
name: { type: String },
|
||||
email: { type: String },
|
||||
email,
|
||||
phone: { type: String },
|
||||
role: { type: String }
|
||||
}]
|
||||
|
|
@ -85,7 +99,7 @@ const OrganizationVersion = {
|
|||
|
||||
const Organization = new Schema({
|
||||
adminName: { type: String, required: true },
|
||||
email: { type: String, required: true },
|
||||
email,
|
||||
token: { type: String, required: true },
|
||||
slugs: [{ type: String }], // aliases system
|
||||
validationState: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue