Class: Metasploit::Framework::FilePathValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Metasploit::Framework::FilePathValidator
- Defined in:
- app/validators/metasploit/framework/file_path_validator.rb
Overview
This is a ActiveModel custom validator that assumes the attribute is supposed to be the path to a regular file. It checks whether the file exists and whether or not it is a regular file.
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
8 9 10 11 12 |
# File 'app/validators/metasploit/framework/file_path_validator.rb', line 8 def validate_each(record, attribute, value) unless value && ::File.file?(value) record.errors.add(attribute, ([:message] || "is not a valid path to a regular file")) end end |