UNPKG

nigeria-validator

Version:

Validate and format common Nigerian data: phone numbers, BVNs, bank codes, etc.

28 lines (23 loc) 601 B
// src/geo.js const stateLgas = require("../data/states-lgas.json"); /** * Check if a given state name exists */ const isValidState = (state) => { return Object.prototype.hasOwnProperty.call(stateLgas, state); }; /** * Get all LGAs for a given state */ const getLGAs = (state) => { return stateLgas[state] || null; }; /** * Check if a specific LGA exists in a given state */ const isValidLGA = (state, lga) => { const lgas = stateLgas[state]; if (!lgas) return false; return lgas.includes(lga); }; module.exports = { isValidState, getLGAs, isValidLGA };