Meteor-Community-Packages / Meteor-Community-Packages/meteor-simple-schema

AutoConvert Issue: String Field Accepts Object Containing a String

Open
#749 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
914
Forks
162
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

Hey Simple-schema team,
First off, thanks for all your amazing work! I've run into a confusing situation and would appreciate some clarification. When using a string field, it seems that passing an object that contains a string (e.g., `{ foo: 'bar' }`) still passes validation. Did I misunderstand how `autoConvert` works, or is this behavior a bug?

**To Reproduce**

- Set `autoConvert` to `true` (or leave it at its default setting)
- Define a field with type `String`
- Pass an object containing a string to that field, for example:
```js
{ 'stripeInvoice.invoiceUrl': { foo: 'bar' } }
```
- Notice that the validation passes unexpectedly

**Expected behavior**

I expected the validation to fail when an object is provided, even if it contains a string. I understand that `autoConvert` performs some conversions for string fields by default when not explicitly disabled, but I assumed that objects with string values would not be automatically converted. Clarification on this behavior would be appreciated.

**Screenshots**

![Image](https://github.com/user-attachments/assets/a775bef8-efb6-487f-b526-ac16b7b10959)

**Versions (please complete the following information):**
- Meteor version: [2.16]
- Browser: [Chrome]
- Version: [1.13.1] (I know we haven't been able to upgrade to the latest version, but we will be soon)

**Additional context**

This is my first ever question on a GitHub repo. Please let me know if any further details are needed. Thanks again for your support! 🙏

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported case with autoConvert enabled, a String field, and the `{ 'stripeInvoice.invoiceUrl': { foo: 'bar' } }` value. Review the autoConvert behavior and existing validation expectations; the issue does not name a source file or test, and done would require deciding whether this conversion should be rejected or clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.