private void createValidators() { shortNameValidator = new ObservableRuleBasedValidator(); BooleanBinding uniqueName = Bindings.createBooleanBinding( () -> { if (organisationProperty().get() != null) { return Utilities.shortnameIsUnique( shortNameProperty().get(), modelWrapper.get(), organisationProperty().get().getTeams()); } else { return true; // no project means this isn't for real yet. } }, shortNameProperty(), organisationProperty()); shortNameValidator.addRule( shortNameProperty().isNotNull(), ValidationMessage.error("Name must not be empty")); shortNameValidator.addRule( shortNameProperty().length().greaterThan(0), ValidationMessage.error("Name must not be empty")); shortNameValidator.addRule( shortNameProperty().length().lessThan(Utilities.SHORT_NAME_MAX_LENGTH), ValidationMessage.error( "Name must be less than " + Utilities.SHORT_NAME_MAX_LENGTH + " characters")); shortNameValidator.addRule( uniqueName, ValidationMessage.error("Name must be unique within organisation")); descriptionValidator = new ObservableRuleBasedValidator(); // always true // the other validators are input-constrained so need not be validated productOwnerValidator = new ObservableRuleBasedValidator(); // always true scrumMasterValidator = new ObservableRuleBasedValidator(); // always true teamMembersValidator = new ObservableRuleBasedValidator(); // always true devTeamValidator = new ObservableRuleBasedValidator(); // always true allValidator = new CompositeValidator( shortNameValidator, descriptionValidator, productOwnerValidator, scrumMasterValidator, teamMembersValidator, devTeamValidator); }
protected ValidationStatus devTeamValidation() { return devTeamValidator.getValidationStatus(); }
protected ValidationStatus teamMembersValidation() { return teamMembersValidator.getValidationStatus(); }
protected ValidationStatus scrumMasterValidation() { return scrumMasterValidator.getValidationStatus(); }
protected ValidationStatus productOwnerValidation() { return productOwnerValidator.getValidationStatus(); }
protected ValidationStatus descriptionValidation() { return descriptionValidator.getValidationStatus(); }
protected ValidationStatus shortNameValidation() { return shortNameValidator.getValidationStatus(); }