Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Add DUNS number validation on profile page #425

Closed
mtorres253 opened this issue Apr 18, 2016 · 16 comments
Closed

Add DUNS number validation on profile page #425

mtorres253 opened this issue Apr 18, 2016 · 16 comments
Assignees

Comments

@mtorres253
Copy link
Contributor

mtorres253 commented Apr 18, 2016

As a registered vendor, I want to know whether the DUNS number I've entered for my profile is not formatted correctly, so that I can correct it before it gets saved to my profile, so the system should check to see if it is correctly formatted

Scenario: System checks that value for DUNS number is actually a number
Given that I am a registered vendor
And I have entered a DUNS number on my profile page
And the DUNS number is not formatted properly (it needs to be a number)
When I click the "Save" button
I should see an error message "The DUNS number you have entered is invalid: The value for this field has to be a number")
And my DUNS number should not be saved to my profile

@jessieay jessieay self-assigned this Apr 18, 2016
@jessieay
Copy link
Contributor

One issue I am having with this is that we have a trait in our factories:

trait :with_duns_in_sam do
  duns_number { '130477032' }
end

I see that this duns_number is also in data/auctions.json -- what is the history behind this duns number? Looks like the rest of the duns_numbers do start with 0 but that one does not and so it is invalid according to the rules in this story.

@adelevie @harrisj do you know the history behind this special ❄️ duns? Is it the only one that won't start with a 0?

@jessieay
Copy link
Contributor

I take that back, there are other DUNs numbers in there that do not start with 0. Perhaps they were entered incorrectly in pre-validation times?

@jessieay
Copy link
Contributor

ah ha! it looks like formatting is slightly more complicated than we thought: https://github.com/18f/samwise/tree/micropurchase-compatibility#format-a-duns-number

must start with 0 if it is 8 digits!

@jessieay
Copy link
Contributor

@harrisj
Copy link
Contributor

harrisj commented Apr 19, 2016

Oh nice. @jessieay, I will talk about Cucumber tomorrow with you

@jessieay
Copy link
Contributor

@mtorres253 if you see my comment above, the formatting referenced in the original GH issue description is not accurate. Will move forward with formatting validation but error msg and rules will be different.

@mtorres253
Copy link
Contributor Author

mtorres253 commented Apr 19, 2016

@jessieay Let's just check to see if it is a number. I don't want to build duplicate validation logic in our system when there is an API we can use to validate the format of the number. I'll add a separate story for that integration.

@adelevie
Copy link
Contributor

Did the docs/code in samwise clear this up, or is there any way I can be helpful here?

@mtorres253
Copy link
Contributor Author

mtorres253 commented Apr 19, 2016

Maybe @adelevie @jessieay . According to samwise, the DUNS number format is 0XXXXXXXX0000 with the Xs being numbers. So a properly formatted DUNS number is:

  1. A number
  2. 8, 9 or 13 digits
  3. In this format 0XXXXXXXX0000

This story started out as a simple validation to ensure that the user is entering a number, so I'm fine just going back to that, and implementing the other checks later in another story.

@adelevie
Copy link
Contributor

adelevie commented Apr 19, 2016

so I'm fine just going back to that, and implementing the other checks later in another story.

👍

jessieay pushed a commit that referenced this issue Apr 19, 2016
* Validate that it contains only integers
* Validate that it is between 8 and 13 characters long

#425
@jessieay
Copy link
Contributor

PR for validating that it's only numbers and between 8 and 13 characters is here: #438

jessieay pushed a commit that referenced this issue Apr 21, 2016
* Validate that it contains only integers
* Validate that it is between 8 and 13 characters long

#425
jessieay pushed a commit that referenced this issue Apr 21, 2016
* Validate that it contains only integers
* Validate that it is between 8 and 13 characters long

#425
jessieay pushed a commit that referenced this issue Apr 21, 2016
* Use samwise to validate format
* Validate that it contains only integers

#425
jessieay pushed a commit that referenced this issue Apr 21, 2016
* Use samwise to validate format
* Validate that it contains only integers

#425
jessieay pushed a commit that referenced this issue Apr 21, 2016
* Use samwise to validate format
* Validate that it contains only integers

#425
jessieay pushed a commit that referenced this issue Apr 21, 2016
* Use samwise to validate format
* Validate that it contains only integers

#425
@jessieay
Copy link
Contributor

closed via #445

@vdavez
Copy link
Contributor

vdavez commented Apr 23, 2016

Based on my read of #445, it looks like it doesn't matter, but I thought you should know (because I didn't!) that there are valid seven-digit DUNS numbers. See 18F/samwise#15.

@jessieay
Copy link
Contributor

@vzvenyach

Thank you for pointing that out. We are using samwise to format so it looks like 7 digits does work:

irb(main):003:0> Samwise::Util.format_duns(duns: '1234567')
=> "0012345670000"
irb(main):004:0> Samwise::Util.format_duns(duns: '12345678')
=> "0123456780000"

But, the samwise README does not reflect this: https://github.com/18f/samwise/tree/micropurchase-compatibility#format-a-duns-number

will do a PR to the README to clarify

@jessieay
Copy link
Contributor

PR 18F/samwise#25

@vdavez
Copy link
Contributor

vdavez commented Apr 25, 2016

Nice! Thanks @jessieay!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants