tidy up validation for users.
This commit is contained in:
+3
-2
@@ -318,8 +318,9 @@ validation.msg.username.already.exists.in.organisation=An account with that user
|
||||
validation.msg.user.firstname.cannot.be.blank=Firstname cannot be blank.
|
||||
validation.msg.user.lastname.cannot.be.blank=Lastname cannot be blank.
|
||||
validation.msg.user.email.cannot.be.blank=Email cannot be blank.
|
||||
validation.msg.user.office.cannot.be.blank=You must select an office.
|
||||
validation.msg.user.roles.cannot.be.blank=A user must have at least one role.
|
||||
validation.msg.user.officeId.cannot.be.blank=You must select an office.
|
||||
validation.msg.user.officeId.not.greater.than.zero=You must select an office.
|
||||
validation.msg.user.roles.cannot.be.empty=A user must have at least one role.
|
||||
validation.msg.changepassword.password.cannot.be.blank=Password cannot be blank.
|
||||
validation.msg.changepassword.passwordrepeat.cannot.be.blank=Repeated password cannot be blank.
|
||||
validation.msg.changepassword.passwordrepeat.not.the.same=Password and Repeat password are not the same.
|
||||
|
||||
+2
-1
@@ -316,7 +316,8 @@ validation.msg.username.already.exists.in.organisation=An account with that user
|
||||
validation.msg.user.firstname.cannot.be.blank=Firstname cannot be blank.(fr)
|
||||
validation.msg.user.lastname.cannot.be.blank=Lastname cannot be blank.(fr)
|
||||
validation.msg.user.email.cannot.be.blank=Email cannot be blank.(fr)
|
||||
validation.msg.user.office.cannot.be.blank=You must select an office.(fr)
|
||||
validation.msg.user.officeId.cannot.be.blank=You must select an office.(fr)
|
||||
validation.msg.user.officeId.not.greater.than.zero=You must select an office.(fr)
|
||||
validation.msg.user.roles.cannot.be.blank=A user must have at least one role.(fr)
|
||||
validation.msg.changepassword.password.cannot.be.blank=Password cannot be blank.(fr)
|
||||
validation.msg.changepassword.passwordrepeat.cannot.be.blank=Repeated password cannot be blank.(fr)
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DataValidatorBuilder {
|
||||
Object[] array = (Object[]) value;
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.empty");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be empty. You must select at least one permission.");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be empty. You must select at least one.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class UserCommandValidator {
|
||||
baseDataValidator.reset().parameter("firstname").value(command.getFirstname()).ignoreIfNull().notBlank();
|
||||
baseDataValidator.reset().parameter("lastname").value(command.getLastname()).ignoreIfNull().notBlank();
|
||||
baseDataValidator.reset().parameter("email").value(command.getEmail()).ignoreIfNull().notBlank();
|
||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).ignoreIfNull().notNull();
|
||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).ignoreIfNull().notNull().greaterThanZero();
|
||||
baseDataValidator.reset().parameter("roles").value(command.getRoles()).ignoreIfNull().arrayNotEmpty();
|
||||
|
||||
baseDataValidator.reset().parameter("password").value(command.getPassword()).ignoreIfNull().notBlank();
|
||||
@@ -51,7 +51,7 @@ public class UserCommandValidator {
|
||||
baseDataValidator.reset().parameter("firstname").value(command.getFirstname()).notBlank();
|
||||
baseDataValidator.reset().parameter("lastname").value(command.getLastname()).notBlank();
|
||||
baseDataValidator.reset().parameter("email").value(command.getEmail()).notBlank();
|
||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).notNull();
|
||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).notNull().greaterThanZero();
|
||||
baseDataValidator.reset().parameter("roles").value(command.getRoles()).arrayNotEmpty();
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user