@@ -73,7 +73,7 @@ import { FieldPath } from './field_path';
73
73
import {
74
74
validateCollectionPath ,
75
75
validateDocumentPath ,
76
- validateExactNumberOfArgs ,
76
+ validateNonEmptyString ,
77
77
validatePositiveNumber
78
78
} from '../../../src/util/input_validation' ;
79
79
import { newSerializer } from '../../../src/platform/serializer' ;
@@ -335,8 +335,6 @@ export function where(
335
335
opStr : WhereFilterOp ,
336
336
value : unknown
337
337
) : QueryConstraint {
338
- // TODO(firestorelite): Consider validating the enum strings (note that
339
- // TypeScript does not support passing invalid values).
340
338
const op = opStr as Operator ;
341
339
const field = fieldPathFromArgument ( 'where' , fieldPath ) ;
342
340
return new QueryFilterConstraint ( field , op , value ) ;
@@ -381,8 +379,6 @@ export function orderBy(
381
379
fieldPath : string | FieldPath ,
382
380
directionStr : OrderByDirection = 'asc'
383
381
) : QueryConstraint {
384
- // TODO(firestorelite): Consider validating the enum strings (note that
385
- // TypeScript does not support passing invalid values).
386
382
const direction = directionStr as Direction ;
387
383
const path = fieldPathFromArgument ( 'orderBy' , fieldPath ) ;
388
384
return new QueryOrderByConstraint ( path , direction ) ;
@@ -597,7 +593,6 @@ function newQueryBoundFromDocOrFields<T>(
597
593
before : boolean
598
594
) : Bound {
599
595
if ( docOrFields [ 0 ] instanceof DocumentSnapshot ) {
600
- validateExactNumberOfArgs ( methodName , docOrFields , 1 ) ;
601
596
return newQueryBoundFromDocument (
602
597
query . _query ,
603
598
query . firestore . _databaseId ,
@@ -738,7 +733,7 @@ export function collection(
738
733
path : string ,
739
734
...pathSegments : string [ ]
740
735
) : CollectionReference < DocumentData > {
741
- validateNonEmptyArgument ( 'collection' , 'path' , path ) ;
736
+ validateNonEmptyString ( 'collection' , 'path' , path ) ;
742
737
if ( parent instanceof FirebaseFirestore ) {
743
738
const absolutePath = ResourcePath . fromString ( path , ...pathSegments ) ;
744
739
validateCollectionPath ( absolutePath ) ;
@@ -785,7 +780,7 @@ export function collectionGroup(
785
780
firestore : FirebaseFirestore ,
786
781
collectionId : string
787
782
) : Query < DocumentData > {
788
- validateNonEmptyArgument ( 'collectionGroup' , 'collection id' , collectionId ) ;
783
+ validateNonEmptyString ( 'collectionGroup' , 'collection id' , collectionId ) ;
789
784
if ( collectionId . indexOf ( '/' ) >= 0 ) {
790
785
throw new FirestoreError (
791
786
Code . INVALID_ARGUMENT ,
@@ -868,7 +863,7 @@ export function doc<T>(
868
863
if ( arguments . length === 1 ) {
869
864
path = AutoId . newId ( ) ;
870
865
}
871
- validateNonEmptyArgument ( 'doc' , 'path' , path ) ;
866
+ validateNonEmptyString ( 'doc' , 'path' , path ) ;
872
867
873
868
if ( parent instanceof FirebaseFirestore ) {
874
869
const absolutePath = ResourcePath . fromString ( path , ...pathSegments ) ;
@@ -1234,16 +1229,3 @@ export function newUserDataReader(
1234
1229
serializer
1235
1230
) ;
1236
1231
}
1237
-
1238
- function validateNonEmptyArgument (
1239
- functionName : string ,
1240
- argumentName : string ,
1241
- argument ?: string
1242
- ) : asserts argument is string {
1243
- if ( ! argument ) {
1244
- throw new FirestoreError (
1245
- Code . INVALID_ARGUMENT ,
1246
- `Function ${ functionName } () cannot be called with an empty ${ argumentName } .`
1247
- ) ;
1248
- }
1249
- }
0 commit comments