//enforces all the mandatory conditions
private void enforceBusinessRules(){
EsimsUtils.validateStrings(this.schoolName,64);
EsimsUtils.validateStrings(this.schoolCode,3);
if(schoolCode.length()<3)
throw new BusinessRuleException("The school code must be 3 characters in length");
EsimsUtils.validateStrings(this.addressLine1,64);
EsimsUtils.validateStrings(this.addressLine2,64);
EsimsUtils.validateNullableStrings(this.addressLine3,64);
EsimsUtils.validateStrings(this.district,32);
EsimsUtils.validateStrings(this.state,32);
//can be only India
EsimsUtils.validateStrings(this.country,5);
EsimsUtils.validateStrings(this.pincode, 6);
EsimsUtils.validateStrings(this.phone1, 10);
if(! this.phone1.matches("[0-9]*"))
throw new BusinessRuleException("Phone no: can be only numbers");
EsimsUtils.validateNullableStrings(this.phone2, 10);
if(this.phone2 !=null)
if (! this.phone2.matches("[0-9]*"))
throw new BusinessRuleException("Phone no: can be only numbers");
EsimsUtils.validateNullableStrings(this.phone3, 10);
if (this.phone3 !=null)
if (! this.phone3.matches("[0-9]*"))
throw new BusinessRuleException("Phone no: can be only numbers");
EsimsUtils.validateNullableStrings(this.email, 32);
if (this.email != null)
if(! this.email.matches("^.+@[^\\.].*\\.[a-z]{2,}$"))
throw new BusinessRuleException("Invalid email address");
EsimsUtils.validateNullableStrings(this.fax, 10);
EsimsUtils.validateStrings(this.management, 64);
EsimsUtils.validateStrings(this.principalFirstName, 32);
EsimsUtils.validateNullableStrings(this.principalMiddleName, 32);
EsimsUtils.validateStrings(this.principalLastName, 32);
EsimsUtils.validateNullableStrings(this.vicePrincipalFirstName, 32);
EsimsUtils.validateNullableStrings(this.vicePrincipalMiddleName, 32);
EsimsUtils.validateNullableStrings(this.vicePrincipalLastName, 32);
EsimsUtils.validateStrings(this.boardOfEducation, 64);
if(this.isActive == null)
throw new BusinessRuleException("Activity status found null");
}