A simple regex based exhaustive validator for PIN codes in India
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
india-pincode-regex/tests/validate_spec.rb

15 lines
456 B

require 'pincode_validator'
describe PincodeValidator do
it 'should validate pincodes' do
['244713', '560029', '560030', '110011'].each do |pin|
expect(described_class::valid? pin).to eq(true)
end
end
it 'should validate incorrect pincodes' do
['999999', '99999', '9999', '999', '99', '9', '111111', '2447131'].each do |pin|
expect(described_class::valid? pin).to eq(false), "#{pin} should be invalid"
end
end
end