tidy up validation order of staff.
This commit is contained in:
+9
-9
@@ -46,15 +46,15 @@ public final class StaffCommandFromApiJsonDeserializer {
|
||||
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
|
||||
final Long officeId = fromApiJsonHelper.extractLongNamed("officeId", element);
|
||||
baseDataValidator.reset().parameter("officeId").value(officeId).notNull().integerGreaterThanZero();
|
||||
|
||||
final String firstname = fromApiJsonHelper.extractStringNamed("firstname", element);
|
||||
baseDataValidator.reset().parameter("firstname").value(firstname).notBlank().notExceedingLengthOf(50);
|
||||
|
||||
final String lastname = fromApiJsonHelper.extractStringNamed("lastname", element);
|
||||
baseDataValidator.reset().parameter("lastname").value(lastname).notBlank().notExceedingLengthOf(50);
|
||||
|
||||
final Long officeId = fromApiJsonHelper.extractLongNamed("officeId", element);
|
||||
baseDataValidator.reset().parameter("officeId").value(officeId).notNull().integerGreaterThanZero();
|
||||
|
||||
if (fromApiJsonHelper.parameterExists("isLoanOfficer", element)) {
|
||||
final Boolean loanOfficerFlag = fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element);
|
||||
baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull();
|
||||
@@ -71,8 +71,13 @@ public final class StaffCommandFromApiJsonDeserializer {
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("staff");
|
||||
|
||||
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
if (fromApiJsonHelper.parameterExists("officeId", element)) {
|
||||
final Long officeId = fromApiJsonHelper.extractLongNamed("officeId", element);
|
||||
baseDataValidator.reset().parameter("officeId").value(officeId).notNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (fromApiJsonHelper.parameterExists("firstname", element)) {
|
||||
final String firstname = fromApiJsonHelper.extractStringNamed("firstname", element);
|
||||
baseDataValidator.reset().parameter("firstname").value(firstname).notBlank().notExceedingLengthOf(50);
|
||||
@@ -83,11 +88,6 @@ public final class StaffCommandFromApiJsonDeserializer {
|
||||
baseDataValidator.reset().parameter("lastname").value(lastname).notBlank().notExceedingLengthOf(50);
|
||||
}
|
||||
|
||||
if (fromApiJsonHelper.parameterExists("officeId", element)) {
|
||||
final Long officeId = fromApiJsonHelper.extractLongNamed("officeId", element);
|
||||
baseDataValidator.reset().parameter("officeId").value(officeId).notNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (fromApiJsonHelper.parameterExists("isLoanOfficer", element)) {
|
||||
final Boolean loanOfficerFlag = fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element);
|
||||
baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull();
|
||||
|
||||
Reference in New Issue
Block a user