question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

trim: false does not work

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
aldeedcommented, Aug 24, 2016

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.

1reaction
nickredmarkcommented, May 6, 2016

Found a workaround:

            Collection.update(id,  {/*your update*/}, {
                removeEmptyStrings: false,
                trimStrings: false
            });
Read more comments on GitHub >

github_iconTop Results From Across the Web

data-ng-trim="false" is not working in angular
when I clicked sign in button , mu user name white spaces are trim off. But I want that white spaces in my...
Read more >
ng-trim should not trim the view value · Issue #16087
As ng-trim is removing all the whitespace off the front of the view value it means the textarea's height doesn't update properly. We...
Read more >
How To Trim False Eyelashes At Home
With most false lashes, some trimming is going to be necessary. Practice and patience are all it really takes to get the perfect...
Read more >
Easy Ways to Trim False Eyelashes: 7 Steps (with Pictures)
1. Hold the lash up to your eye to measure the correct fit. Looking in the mirror, place the lash just above your...
Read more >
Re: [angular.js] Angularjs will trim the content of a model ...
If I input something which has leading or ending spaces, it will be trimmed when displaying it. How to let angularjs not do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found