trim: false does not work
See original GitHub issueI’m getting some weird saving behavior when a string starts or ends with whitespace, even when trim: false
is set, where SimpleSchema converts a string to a string and trims off whitespace. I’m also getting some weird behavior where some strings are getting oddly mutated upon save. I do not know if these issues are related but it seems possible.
Log:
SimpleSchema.clean: autoconverted value <a href='javascript:void(0);' data-context-id='15'>In 1976</a>, Ebola first emerged in Sudan and Zaire, two countries in <a href='javascript:void(0);' data-context-id='15'>Central Africa</a>. This outbreak killed approximately 300 people, and although epidemiologists studied the area extensively, Ebola’s natural reservoir in the environment was never discovered. In 1989, Ebola was also discovered in the Philippines, after monkeys infected with the disease were exported from there to an animal testing laboratory in Reston, Virginia in the United States.
from string to string for draftStory.verticalSections.$.content
Relevant part of my schema:
'content': {
type: String,
trim: false
},
https://github.com/readFOLD/FOLD/blob/9b983fd3c92cb17644bba5aad5817a64d78f996c/collections/collections.js#L1219 + https://github.com/readFOLD/FOLD/blob/9b983fd3c92cb17644bba5aad5817a64d78f996c/collections/collections.js#L1257
Object is inserted here: https://github.com/readFOLD/FOLD/blob/9b983fd3c92cb17644bba5aad5817a64d78f996c/server/fixtures.js#L76 It’s pretty vanilla but does end with a space, which is trimmed.
Issue Analytics
- State:
- Created 8 years ago
- Comments:11
Top GitHub Comments
Thanks for your patience. SimpleSchema 2.0.0-rc.1 is now released and should fix this bug.
There are a number of breaking changes when updating to 2.0, so be sure to check out the change log. If you use aldeed:collection2, you will need to use 2.10.0 or higher of that package in order to use SimpleSchema 2.0. If you use autoform, it is not yet updated to work with SimpleSchema 2.0, but hopefully soon.
SimpleSchema is now an isomorphic NPM package, so you can check out the updated readme and file issues over at the other repo. The Meteor wrapper package will exist for now but eventually I will probably deprecate support for it.
This is still a beta/RC and I do expect people will find issues, so use with caution. Production use is not yet recommended. That said, there are more and better unit tests than ever before, and the codebase should be much easier for others to read through and debug quickly.
Found a workaround: