Phone number validator for Adonisjs

Usage no npm install needed!

<script type="module">
  import shagitalAdonisjsPhoneValidator from 'https://cdn.skypack.dev/@shagital/adonisjs-phone-validator';


Adonisjs Phone Validator ▲

npm npm (scoped) NPM


Adds phone number validation functionality to Adonisjs on the JS port of Google's libphonenumber API by catamphetamine

Step One - Install

Via Adonis CLI

adonis install @shagital/adonisjs-phone-validator

Via npm/yarn

  • Install package
// via npm
npm require @shagital/adonisjs-phone-validator

// via yarn
yarn add @shagital/adonisjs-phone-validator

Step Two - Register Provider

Open start/app.js and add @shagital/adonisjs-phone-validator/providers/PhoneValidatorProvider to the providers array


You use the phone validation syntax just like you'd normally do validation in Adonisjs. Examples below: NOTE: The country 2-character ISO code is required. You can find all supported codes here

controller method


const { validate } = use('Validator')

class UserController {

  async store ({ request, session, response }) {
    const rules = {
      phone: 'required|phone:NG', // validate Nigerian phone number

    const validation = await validate(request.all(), rules)

    if (validation.fails()) {
      return response.redirect('back')

    return 'Validation passed'



'use strict'

class StoreUser {
  get rules () {
    return {
      phone: 'required|phone:US', // validate a US phone number


Free for all, if you find an issue with the package or think of an improvement, please send in a PR.