rubyforgood / inkind-admin

A project serving Community Education Partnerships - https://www.cep.ngo/ . This Rails application presents an admin interface for CEP to manage their volunteers and students. And provides a GraphQL backend for https://github.com/rubyforgood/inkind-volunteer .
MIT License
9 stars 27 forks source link

Restrict phone number field to the telephone input #192 #195

Closed JelenaD1 closed 2 years ago

JelenaD1 commented 2 years ago

Resolves #192

Description

This PR is adding validation on phone_number. Number can not be blank and must be 10 digits long. Before we move on and add specs we need clarification on the phone number format. Format we added does not allow any space or - between the digits. Once we clarify that is a format we want we will go ahead and add specs for student and user model as well.

Type of change

Screenshots

INKIND INKIND INKIND
JelenaD1 commented 2 years ago

@garettarrowood We added a simple validation for presence and for a length. Before we update the specs we wanted clarification on the phone number format. Right now we don't allow any space between the digits or any -. Is that fine or do we want different format?

garettarrowood commented 2 years ago

Our main branch has gotten a little out of whack.

If you'd like to continue to work on this, please cherry-pick these two commits and open up a fresh PR. Sorry for the inconvenience!

In regards to your question, I believe one solution may be to strip all -, (, ), ` and.` out of the input, then validate the length of 10 numeric characters.

cc/ @RudeChowder