Class: Serega::SeregaValidations::Attribute::CheckName
- Inherits:
-
Object
- Object
- Serega::SeregaValidations::Attribute::CheckName
- Defined in:
- lib/serega/validations/attribute/check_name.rb
Overview
Attribute name
parameter validator
Class Method Summary collapse
-
.call(name) ⇒ void
Checks allowed characters.
Class Method Details
.call(name) ⇒ void
This method returns an undefined value.
Checks allowed characters. Globally allowed characters: "a-z", "A-Z", "0-9". Minus and low line "-", "_" also allowed except as the first or last character.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/serega/validations/attribute/check_name.rb', line 29 def call(name) name = name.to_s valid = case name.size when 0 then false when 1 then name.match?(FORMAT_ONE_CHAR) else name.match?(FORMAT_MANY_CHARS) end return if valid raise SeregaError, (name) end |