Setting unique: true won't work
See original GitHub issueHi, I have setup a field to be unique using unique: true
. I’m trying to validate it in the client and use invalidKeys()
to get all the errors. But I can’t see the uniqueness error in there! Looks like it will allow me to add duplicate values?
I’m trying to set one field to be unique using simple schema. But no matter what I do it’s not working. Here’s how I set it up :
let schema = new SimpleSchema({
name: {
type: String,
label: 'Committee name',
max: 200
},
shortName: {
type: String,
label: 'Short name',
max: 10,
index: true,
sparse: true,
unique: true,
autoValue: (com) => {
if (com.shortName) {
return com.shortName.toLowerCase();
}
}
},
});
I even tried to reset meteor. If I add a duplicate value, it won’t add the record but won’t even give any errors when validating.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8
Top Results From Across the Web
Why @Column(unique = true) does not work? - Stack Overflow
It create object in entity. Problem is because I can multiply this object again and again instead of unique = true in columns...
Read more >Setting unique: true won't work #605 - GitHub
I'm trying to set one field to be unique using simple schema. But no matter what I do it's not working. Here's how...
Read more >Model field reference - Django documentation
If the built-in fields don't do the trick, you can try django-localflavor ... One exception is when a CharField has both unique=True and...
Read more >UNIQUE function - Microsoft Support
Learn about the UNIQUE function, which returns a list of unique values in a list or range. UNIQUE is in a class of...
Read more >Unique partial index is not working with mongoose on email
I tested this (with or without mongoose-unique-validator) by setting 'terms_accepted' to true and false, email index doesn't work on saving ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1
Hi @aldeed,
I’ve installed aldeed:meteor-collection2 wich automatically install simple-schema & schema-index.
But still no validation for ‘unique’