Skip to content

Commit

Permalink
fix: add quotes to field name to avoid ambiguity (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
skos-ninja authored and schmidt-sebastian committed Jan 6, 2020
1 parent 87543e2 commit 8caee71
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dev/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export function validateUserInput(
level = level || 0;
inArray = inArray || false;

const fieldPathMessage = path ? ` (found in field ${path})` : '';
const fieldPathMessage = path ? ` (found in field "${path}")` : '';

if (Array.isArray(value)) {
for (let i = 0; i < value.length; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion dev/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function customObjectMessage(
value: unknown,
path?: FieldPath
): string {
const fieldPathMessage = path ? ` (found in field ${path})` : '';
const fieldPathMessage = path ? ` (found in field "${path}")` : '';

if (isObject(value)) {
// We use the base class name as the type name as the sentinel classes
Expand Down
12 changes: 6 additions & 6 deletions dev/test/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,22 @@ describe('serialize document', () => {
expect(() => {
firestore.doc('collectionId/documentId').set({foo: undefined});
}).to.throw(
'Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field foo).'
'Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "foo").'
);

expect(() => {
firestore.doc('collectionId/documentId').set({
foo: FieldPath.documentId(),
});
}).to.throw(
'Value for argument "data" is not a valid Firestore document. Cannot use object of type "FieldPath" as a Firestore value (found in field foo).'
'Value for argument "data" is not a valid Firestore document. Cannot use object of type "FieldPath" as a Firestore value (found in field "foo").'
);

expect(() => {
class Foo {}
firestore.doc('collectionId/documentId').set({foo: new Foo()});
}).to.throw(
'Value for argument "data" is not a valid Firestore document. Couldn\'t serialize object of type "Foo" (found in field foo). Firestore doesn\'t support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).'
'Value for argument "data" is not a valid Firestore document. Couldn\'t serialize object of type "Foo" (found in field "foo"). Firestore doesn\'t support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).'
);

expect(() => {
Expand Down Expand Up @@ -1238,7 +1238,7 @@ describe('set document', () => {
expect(() => {
firestore.doc('collectionId/documentId').set({foo: FieldValue.delete()});
}).to.throw(
'Value for argument "data" is not a valid Firestore document. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field foo).'
'Value for argument "data" is not a valid Firestore document. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field "foo").'
);
});

Expand Down Expand Up @@ -1587,15 +1587,15 @@ describe('update document', () => {
a: {b: FieldValue.delete()},
});
}).to.throw(
'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Value for argument "dataOrField" is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field a.b).'
'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Value for argument "dataOrField" is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field "a.b").'
);

expect(() => {
firestore.doc('collectionId/documentId').update('a', {
b: FieldValue.delete(),
});
}).to.throw(
'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Element at index 1 is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field a.b).'
'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Element at index 1 is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field "a.b").'
);

expect(() => {
Expand Down

0 comments on commit 8caee71

Please sign in to comment.