Class: YDIM::Html::Util::Validator
- Inherits:
-
SBSM::Validator
- Object
- SBSM::Validator
- YDIM::Html::Util::Validator
- Defined in:
- lib/ydim/html/util/validator.rb
Constant Summary collapse
- BOOLEAN =
[:payment_received, :deleted, :suppress_vat]
- DATES =
[:date, :hosting_invoice_date]
- ALLOWED_TAGS =
%{a b br div font h1 h2 h3 i img invoice li ol p pre span strong u ul year}
- ENUMS =
{ :currency => [ 'CHF', 'EUR', ], :debitor_type => [ nil, 'dt_hosting', 'dt_pharmacy', 'dt_pharma', 'dt_insurance', 'dt_info', 'dt_hospital', 'dt_health', 'dt_doctor', 'dt_consulting' ], :invoice_interval => [ 'inv_12', 'inv_6', 'inv_3', 'inv_24', 'inv_m', ], :salutation => [ nil, 'Frau', 'Herr', ], :status => [ nil, 'is_open', 'is_due', 'is_paid', 'is_trash'], }
- EVENTS =
[ :ajax_collect_garbage, :ajax_create_item, :ajax_debitor, :ajax_delete_autoinvoice, :ajax_delete_item, :ajax_item, :ajax_invoice, :ajax_invoices, :ajax_status, :autoinvoice, :create_autoinvoice, :create_debitor, :create_invoice, :debitor, :debitors, :generate_invoice, :invoice, :invoices, :login, :logout, :pdf, :send_invoice, :sort, :update ]
- STRINGS =
[ :name, :contact, :contact_firstname, :contact_title, :country, :description, :location, :sortvalue, :text, :unit ]
- NUMERIC =
[ :unique_id, :hosting_price, :index, :precision, :price, :quantity ]
- HTML =
[ :reminder_body, :reminder_subject ]
Instance Method Summary collapse
- #address_lines(value) ⇒ Object
- #emails(value) ⇒ Object
- #phone(value) ⇒ Object
- #validate_numeric(key, value) ⇒ Object
Instance Method Details
#address_lines(value) ⇒ Object
34 35 36 |
# File 'lib/ydim/html/util/validator.rb', line 34 def address_lines(value) validate_string(value).split(/\r|\n|\r\n/) end |
#emails(value) ⇒ Object
37 38 39 40 41 |
# File 'lib/ydim/html/util/validator.rb', line 37 def emails(value) value.to_s.split(/\s*,\s*/).collect do |val| email(val) end rescue SBSM::InvalidDataError => err raise SBSM::InvalidDataError.new(err., :emails, value) end |
#phone(value) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/ydim/html/util/validator.rb', line 42 def phone(value) str = value.to_s.strip return if(str.empty?) if(/^00[0-9 ]{10,}$/.match(str)) str else raise SBSM::InvalidDataError.new(:e_invalid_phone, :phone, str) end end |
#validate_numeric(key, value) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/ydim/html/util/validator.rb', line 51 def validate_numeric(key, value) match = /-?\d*(\.\d{1,2})?/.match(value) if(match[1]) match[0].to_f else match[0].to_i end end |