require 'zxcvbn' class ZxcvbnValidator < ActiveModel::EachValidator attr_reader :record, :attribute, :value SCORE_RANGE = (1..4).freeze def initialize(options) unless SCORE_RANGE.include? options[:score] raise ArgumentError, ":range must be a #{SCORE_RANGE.to_s.gsub('..', ' to ')}" end super end def validate_each(record, attribute, value) @record, @attribute, @value = record, attribute, value @sco