Meteor-Community-Packages / meteor-simple-schema

Meteor integration package for simpl-schema
https://github.com/Meteor-Community-Packages/meteor-simple-schema
MIT License
919 stars 161 forks source link

removeEmptyStrings doesn't work #705

Closed zhe1ka closed 6 years ago

zhe1ka commented 7 years ago

Hi, I've some problem when I want to save my object with an empty value of a field. I try to use "removeEmptyStrings", but it doesn't help me. I really don't know what I should do to fix it.

My code

const CompaniesSchema = new SimpleSchema({
    name: {
        type: String,
        defaultValue: ''
    }
}

CompaniesSchema.clean({
    removeEmptyStrings: false
});

const Companies = new Mongo.Collection('Companies');
Companies.attachSchema(CompaniesSchema);

========

Companies.update({ userId: this.userId }, {
    $set: {
        name: '',
    }
})

Exception while invoking method 'saveProfileCompany' Error: Name is required
aldeed commented 6 years ago

The Meteor SimpleSchema package is no longer maintained other than critical fixes to keep it running with each latest Meteor release. Closing non-critical issues in this repo. Anyone who cares about this may do one or more of the following: