Skip to content

Commit

Permalink
Properly trigger validation for unique client-id or provider-id. #54
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Nov 14, 2018
1 parent 5b75761 commit 672ca1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/validators/unique-client-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const UniqueClientId = BaseValidator.extend({

validate(value, options, model) {
let providerId = model.get('provider').get('symbol') + '.';
if (value === providerId || Ember.computed.not('model.meta.id.isEnabled')) {
if (value === providerId) {
return true;
} else {
return this.get('store').query('client', { query: value, 'include-deleted': true }).then((result) => {
return this.get('store').query('client', { id: value }).then((result) => {
if(result.content.length > 0) {
return "The Client ID " + value + " already exists, or existed before and has been deleted. Please contact DataCite staff if you want to create an account with this Client ID.";
return "The Client ID " + value + " already exists, or existed before and has been deleted. Contact DataCite staff if you want to create an account with this Client ID.";
} else {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions app/validators/unique-provider-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const UniqueProviderId = BaseValidator.extend({
store: Ember.inject.service(),

validate(value, options, model) {
if (value.length < 2 || model && Ember.computed.not('model.meta.id.isEnabled')) {
if (value.length < 2) {
return true;
} else {
return this.get('store').query('provider', { query: value, 'include-deleted': true }).then((result) => {
return this.get('store').query('provider', { id: value }).then((result) => {
if(result.content.length > 0) {
return "The Provider ID " + value + " already exists, or existed before and has been deleted. Please contact DataCite staff if you want to create an account with this Provider ID.";
return "The Provider ID " + value + " already exists, or existed before and has been deleted. Contact DataCite staff if you want to create an account with this Provider ID.";
} else {
return true;
}
Expand Down

0 comments on commit 672ca1d

Please sign in to comment.