fixed problem with multiple carts and a whole load of problems with crazy delivery destination logic / if I didn't write it i would have thought it was written by a drug abuser during high
This commit is contained in:
@@ -9,6 +9,7 @@ var ItemCollection = require('../models/itemCollection');
|
||||
var DeliveryDestination = require('../models/deliveryDestination');
|
||||
var OrderConfirmation = require('../models/orderConfirmation');
|
||||
var Place = require('../models/place');
|
||||
var Validation = require('../utils/validation');
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
@@ -141,27 +142,27 @@ var validateDeliveryDestinationForm = function() {
|
||||
_deliveryDestinationErrors = {};
|
||||
|
||||
var nameRegex = /.+\s+.+/i;
|
||||
if (_deliveryDestination.get('name').search(nameRegex) < 0) {
|
||||
if (Validation.safeString(_deliveryDestination.get('name')).search(nameRegex) < 0) {
|
||||
_deliveryDestinationErrors['name'] = "I prezime i ime su obavezni";
|
||||
}
|
||||
|
||||
var addressRegex = /.+\s+.+/i;
|
||||
if (_deliveryDestination.get('address').search(addressRegex) < 0) {
|
||||
if (Validation.safeString(_deliveryDestination.get('address')).search(addressRegex) < 0) {
|
||||
_deliveryDestinationErrors['address'] = "Adresa mora biti ispravna";
|
||||
}
|
||||
|
||||
var emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/i;
|
||||
if (_deliveryDestination.get('email').search(emailRegex) < 0) {
|
||||
if (Validation.safeString(_deliveryDestination.get('email')).search(emailRegex) < 0) {
|
||||
_deliveryDestinationErrors['email'] = "Email mora biti ispravno upisan";
|
||||
}
|
||||
|
||||
var phoneRegex = /[\d\s-]{7,8}/i;
|
||||
if (_deliveryDestination.get('phone').search(phoneRegex) < 0) {
|
||||
if (Validation.safeString(_deliveryDestination.get('phone')).search(phoneRegex) < 0) {
|
||||
_deliveryDestinationErrors['phone'] = "Telefon mora biti ispravan";
|
||||
}
|
||||
|
||||
var placeRegex = /^\s{0,1}\d{5}$/i;
|
||||
if (_deliveryDestination.get('place').search(placeRegex) < 0) {
|
||||
if (Validation.safeString(_deliveryDestination.get('place')).search(placeRegex) < 0){
|
||||
_deliveryDestinationErrors['place'] = "Mjesto mora biti izabrano";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user