houdini/config/state_code_constraint.rb

14 lines
548 B
Ruby
Raw Normal View History

2020-05-19 21:12:13 +00:00
# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
2020-05-19 21:12:13 +00:00
class StateCodeConstraint
US_STATES = %w(AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN
IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ
NM NY NC ND OH OK OR PA PR RI SC SD TN TX UT VT VA WA WV WI WY)
US_STATES_REGEX = Regexp.union(*US_STATES.map{|i| /^#{i.downcase}$/})
def matches?(request)
US_STATES_REGEX =~ request.params[:state_code]
end
end