FieldPath.fromString constructor

FieldPath.fromString(
  1. String path
)

Parses a field path string into a FieldPath, treating dots as separators.

Throws an ArgumentError if path is empty, starts or ends with a dot, contains .., or contains one of ~ * / [ ]; use FieldPath.new for such names.

Implementation

factory FieldPath.fromString(String path) {
  checkNotNull(path, 'Provided field path must not be null.');
  checkArgument(
    !_reserved.hasMatch(path),
    "Invalid field path ($path). Paths must not contain '~', '*', '/', '[', "
    "or ']'. Use FieldPath() for field names that contain them.",
  );
  try {
    return FieldPath(path.split('.'));
  } on ArgumentError catch (_) {
    throw ArgumentError(
      'Invalid field path ($path). Paths must not be empty, begin with \'.\', end with \'.\', '
      'or contain \'..\'',
    );
  }
}