Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker for current/new ideas #4

Open
ricardoerl opened this issue May 8, 2020 · 10 comments
Open

Tracker for current/new ideas #4

ricardoerl opened this issue May 8, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@ricardoerl
Copy link

ricardoerl commented May 8, 2020

I bet there are more ideas on how to keep expanding the library. We can use this issue as initial tracker.

If you like the idea, we can discuss the proposals in the thread and I can update the list here. Then we can migrate the list to the Projects tab or even have it in the readme.

Util Status
isDUI Published
isNIT Published
isPhoneNumber In progress
getPhoneNumberDetails In progress
isPassport Proposal
isPassportFormat Proposal
@jonathanpalma jonathanpalma added the enhancement New feature or request label May 8, 2020
@jonathanpalma
Copy link
Owner

Hey @ricardoerl, I like the idea of discussing proposals in this thread, I guess then we can create "feature requests" using the issue template that is already place, so later these can be tracked using Projects.

I was thinking on a couple ones

  • Phone number validation (mobile/residential)
  • Dictionary of Municipalities, Departments

@leosuncin
Copy link
Contributor

leosuncin commented Jun 21, 2020

I found the registry of residential and mobile phone numbers, with a scrapping script pull the data and save to CSV or JSON to be used or something more simple like a regex

function isPhoneNumber(phone) {
  const phoneNumberRegex = /^[267]\d{3}-\d{4}$/;
  return phoneNumberRegex.test(phone);
}

@jonathanpalma
Copy link
Owner

Hey @leosuncin, that's a great one.

What do you think about integrating both of them?

isPhoneNumber

Verifies that given Phone Number format is valid

  • isMobilePhoneNumber (/^[67]\d{3}-\d{4}$/)
  • isResidentialPhoneNumber (/^[2]\d{3}-\d{4}$/)

getPhoneNumberDetails

Get phone numbers details using the information provided by SIGET (we can even use the isMobilePhoneNumber / isResidentialPhoneNumber functions to have a single one for both scenarios residential and mobile)

i.e. getPhoneNumberDetails('7742-0000')

{
  type: 'mobile',
  numberingPlan: {
    owner: 'CTE TELECOM PERSONAL, S.A. de C.V.',
    from: '7740-0000',
    to: '7744-9999',
    qty: 50000,
    resolution: 'T-22-2001',
    assignmentDate: '09/01/2001' // we could even use ISO-format
  }
}

Please let me know if you have any comments or suggestions and we can create a feature request

@leosuncin
Copy link
Contributor

I can open a pull request to add the new to functions, but about the scrapping script I have two proposals:
 

Create a new project

Due the different scope of the new challenge would be a good idea create a new repository with the source code, then run it within a CI environment (maybe Github Actions) every month or so, to scrap the data from the SIGET website and store it in a CSV, JSON and SQLite to be consume it later on, this can be done through a web service, hubdb or Github API.

Add script to this repository

Almost the same above but using only JSON with nanosql to query the data due it works in Node.js and browser.

@jonathanpalma
Copy link
Owner

@leosuncin I would prefer to keep it under the same repository to take advantage of the infrastructure that is already in place. (This repository is currently using CircleCI)

My only concern is related to the way of storing/consuming these resources.

Consuming

To be consumed from an external resource

Pros

  • Smaller bundle size (a couple of Kb, so it shouldn't be a big deal)
  • Can be reused by other people/libs trying to accomplish the same goal

Cons

  • No offline support
  • We will have to take care of Service Availability

To be included within the lib as a minified asset

Pros

  • Offline support
  • Most of this process can be automated using the tools already implemented in this project
  • The extracted information (CSV, JSON) could be still available through GitHub raw content

Cons

  • Larger bundle size (a couple of Kb, so it shouldn't be a big deal either)

Storing

At this moment in which we haven't discussed any other feature where we would need to heavy filter/process data, I don't see the need to implement a DB. Instead, I would suggest applying some normalization (we could even use something like normalizr) and make the calculations using plain algorithms. However, if there is any reason why you think we should use a DB, I am open to discuss it.

Thank you again for your contribution, I am looking forward to your comments ✌️

@leosuncin
Copy link
Contributor

I'm not sure if normalize the data could help cause the keys are a range 7740-0000-7744-9999. I believe a DB library (like NanoSQL or lowdb) would help to query the data.

I don't think the library size could be an issue thanks to bundlers like Rollup, moreover phone number libraries are commonly heavy.

The main pain point is the support for frontend and backend environment, file access in browser is not possible (at least not cross-browser) maybe split the data in JSON files by ranges and lazy loading the required files.
 

async function getPhoneNumberDetails(phone) {
	if (phone > 77400000 && phone < 77449999) {
		const data = await import('./77400000-77449999');
		return data;
	}
	// other ranges
}

@jonathanpalma
Copy link
Owner

@leosuncin sounds great!

Can you please submit the feature request for both isPhoneNumber and getPhoneNumberDetails so we can have better tracking of them?

@jonathanpalma
Copy link
Owner

Before I forget it 👀

@all-contributors please add @ricardoerl for ideas

@allcontributors
Copy link
Contributor

@jonathanpalma

I've put up a pull request to add @ricardoerl! 🎉

@alepaz
Copy link
Contributor

alepaz commented Jun 27, 2020

Hey, @ricardoerl I'd like to add the idea and create the PR to validate a passport:

I have thought in the following methods:

isPassport(passport, DUI)
this method will have to check first if the DUI is valid and is going to use isPassportFormat

isPassportFormat(passport)
this method is only going to validate though regex if the passport is valid

@leosuncin do you know if there any page, repository in which I can check the rules of a passport, or validate that a passport always has the format "A[Your DUI without the validate digit]"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants