Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/validators/postcode_validator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PostcodeValidator < ActiveModel::Validator
VALID_POSTCODE = /^([A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][A-Z]{2})$/i
INVALID_POSTCODE = /^(BF|BX|GIR|XX|GY|JE|IM|AI|GX|VG)/i
INVALID_POSTCODE = /^(BF|BX|GIR|XX|AI|GX|VG)/i
CAYMANS_POSTCODE = /^KY[0-9]-/i

def validate(record)
Expand Down
8 changes: 4 additions & 4 deletions spec/validators/postcode_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def initialize(postcode)
"CR2 6XH",
"DN55 1PT",
"KY11 4JU",
# Crown dependencies
"JE4 3ZZ",
"GY7 3ZZ",
"IM5 3ZZ",
]
end

Expand All @@ -57,10 +61,6 @@ def initialize(postcode)
"AA1 12345",
"AA1",
"AAA 1AA",
# Crown dependencies
"JE4 3ZZ",
"GY7 3ZZ",
"IM5 3ZZ",
# Non-geographic
"GIR 0AA",
"BF1",
Expand Down