Skip to main content

Get started with Common Utilities

Install the package in your project and check your first value.

Before you begin​

You need one of these:

  • For React or Node: Node.js 18 or later, and access to the internal npm registry at https://artifactory.enmovil.net/
  • For Python: Python 3.8 or later, and access to the common_utils repository on gitlab.enmovil.net

The package comes in two forms, released together with the same version and the same rules:

PackageForInstalled from
@enmovil/common-utils (npm)React UI and Node APIsThe internal npm registry
enmovil_common_utils (pip)Python servicesThe common_utils GitLab repository, by release tag

Neither package has runtime dependencies.

Install in a React or Node project​

  1. In your project's .npmrc file, point the @enmovil scope at the internal registry:

    @enmovil:registry=https://artifactory.enmovil.net/
  2. Install the package:

    npm install @enmovil/common-utils
  3. Import the functions that you need:

    import { validators, formatters, helpers, request } from "@enmovil/common-utils";

Install in a Python service​

Install a release by its tag, which matches the npm version:

pip install "git+https://gitlab.enmovil.net/microservices/common_utils.git@v1.1.0#subdirectory=python"

Then import the functions that you need:

from enmovil_common_utils import validators, formatters, helpers, request

If your machine can't reach the public package index, add --no-build-isolation --no-deps to the pip install command. The package has no dependencies, so it doesn't need the index.

Make your first call​

Check a PIN code:

validators("560001", "pincode");   // { valid: true }
validators("56001", "pincode"); // { valid: false, code: "pincode", message: "Enter a valid 6-digit PIN code" }

When the value is valid, you get { valid: true }. When it isn't, you get the code of the check that failed and a message to show.

Upgrade the package​

To move to a new version, change the version in your install command, or run npm install @enmovil/common-utils@<version>. After you upgrade, restart the React dev server, because it doesn't watch node_modules.

Next steps​