function validate() {
	
	var vl = new ValidationLibrary(true);
	vl.resetError();

	vl.assertNotEmpty("Start date is required", f("startdate"));
	vl.assertNotEmpty("End date is required", f("enddate"));
	vl.assertIsDate("Start date must be a date", f("startdate"));
	vl.assertIsDate("End date must be a date", f("enddate"));
	vl.assertNotEmpty("Opening balance is required",f("openingbal"));
	vl.assertNotEmpty("Closing balance is required", f("closingbal"));
	
	vl.ifGreaterThan(f("startdate"), f("enddate"))
		.assert("Start date must be before the end date");
	
	var calculatedclose = vl.sum([f("openingbal"),f("contributions"),f("dividends"),f("capitalgrowth")])
						- vl.sum([f("fees"),f("withdrawals")]);
	
	vl.ifEqual(f("detailsrequired"), "Full")
		.assertAllNotEmpty("If full details are required, contributions, "
							+ " withdrawals, fees, dividends and capital growth"
							+ " must be supplied.",
							[f("contributions"),f("withdrawals"),f("fees"),f("dividends"),f("capitalgrowth")])
		.assertIsNumber("Contribution must be a number",f("contributions"))
		.assertIsNumber("Withdrawals must be a number",f("withdrawals"))
		.assertIsNumber("Fees must be a number",f("fees"))
		.assertIsNumber("Dividends must be a number",f("dividends"))
		.assertIsNumber("Capital growth must be a number",f("capitalgrowth"))
		.assertEqual("The sum of the opening balance, contributions" 
						+ " dividends and capital growth, minus the fees"
						+ " and withdrawals, must equal the closing balance"
						,calculatedclose,f("closingbal"));
	
	vl.ifEqual(f("detailsrequired"), "Part")
	  .assertAllEmpty("If partial details are required, contributions, "
						+ " withdrawals, fees, dividends and capital growth"
						+ " must be empty.",
						[f("contributions"),f("withdrawals"),f("fees"),f("dividends"),f("capitalgrowth")]);


}

