Syntax for json schema validation within Atlas?

All of the examples of JSON schema validation I have found use the following snippet’s format:

db.createCollection("users", {
   validator: {
   $jsonSchema: {
      bsonType: "object",
         required: [ "username", "password" ],
         properties: {
            username: {
               bsonType: "string",
               description: "must be a string and is required"
            },
            password: {
               bsonType: "string",
               minLength: 8,
               description: "must be a string at least 8 characters long, and is required"
            }
         }
      }
   }
} )

If I want the validation to use a schema.JSON file stored within the same Atlas’ collection, what is the syntax to compare adherence to this separate schema file, after the opening ’ $jsonSchema: {…'?

Thank you for helping a noob JSON schema user.

@Stephen_Clark , I see you want to reuse the validator of existing collection . In that case

In mongo shell , you can use

var schema = db.getCollectionInfos({name: "users"})[0].options.validator;
db.createCollection("users1", { validator: schema } );

In driver, i see that getCollectionInfo isn’t available, so you can use listCollections instead

const filter = { name: 'users' };
const collectionInfos = await db.listCollections(filter).toArray();