208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
# File 'lib/XMLFields.rb', line 208
def self.from_hash(hash, name='customerInfo')
base = hash[name]
if(base)
this = CustomerInfo.new
this.ssn = base['ssn']
this.dob = base['dob']
this.customerRegistrationDate = base['customerRegistrationDate']
this.customerType = base['customerType']
this.incomeAmount = base['incomeAmount']
this.incomeCurrency = base['incomeCurrency']
this.customerCheckingAccount = base['customerCheckingAccount']
this.customerSavingAccount = base['customerSavingAccount']
this.employerName = base['employerName']
this.customerWorkTelephone = base['customerWorkTelephone']
this.residenceStatus = base['residenceStatus']
this.yearsAtResidence = base['yearsAtResidence']
this.yearsAtEmployer = base['yearsAtEmployer']
SchemaValidation.validate_regex(this.ssn, false, /\A\d{9}\Z/, name, 'ssn')
SchemaValidation.validate_date(this.dob, false, name, 'dob')
SchemaValidation.validate_regex(this.customerRegistrationDate, false, /\A\d{4}-\d{2}-\d{2}/, name, 'customerRegistrationDate')
SchemaValidation.validate_enum(this.customerType, false, ['New','Existing'], name, 'customerType')
SchemaValidation.validate_long(this.incomeAmount, false, name, 'incomeAmount')
SchemaValidation.validate_currency(this.incomeCurrency, false, name, 'incomeCurrency')
SchemaValidation.validate_boolean(this.customerCheckingAccount, false, name, 'customerCheckingAccount')
SchemaValidation.validate_boolean(this.customerSavingAccount, false, name, 'customerSavingAccount')
SchemaValidation.validate_length(this.employerName, false, 1, 20, name, "employerName")
SchemaValidation.validate_length(this.customerWorkTelephone, false, 1, 20, name, "customerWorkTelephone")
SchemaValidation.validate_enum(this.residenceStatus, false, ['Own','Rent','Other'], name, 'residenceStatus')
SchemaValidation.validate_size(this.yearsAtResidence, false, 0, 99, name, 'yearsAtResidence')
SchemaValidation.validate_size(this.yearsAtEmployer, false, 0, 99, name, 'yearsAtEmployer')
this
else
nil
end
end
|