I have a Meteor AutoForm collection schema with the following field and I am trying to make it unique. It doesn't allow the same value in the same case but when I change the case of the value, value get inserted, so how can I prevent to insert duplicate value with different case?
Like Test
, TEST
, TesT
all having the same spell so it should not get inserted.
I tried this:
Schemas.Organisation = new SimpleSchema({
company: {
type: String,
max: 200,
unique: true,
autoValue: function () {
if (this.isSet && typeof this.value === "string") {
return this.value.toLowerCase();
}
},
autoform:{
label: false,
afFieldInput: {
placeholder: "Enter Company Name",
}
}
}
})
But it is not let me inserted the duplicate value but it converting to all lower case while saving in the db. So how can I save the value as user entered, but value should not have same spell?