Skip to content

Commit

Permalink
correctly trigger validation for duplicate symbol. #54
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Nov 15, 2018
1 parent 34961d7 commit 24fb574
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/models/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ const Validations = buildValidations({
symbol: [
validator('presence', true),
validator('client-id', true),
validator('unique-client-id', true),
validator('unique-client-id', {
presence: true,
disabled: Ember.computed('model', function() {
return !this.get('model').get('isNew');
})
}),
validator('format', {
regex: /^[A-Z]+\.[A-Z0-9]+(-[A-Z0-9]+)?$/,
message: 'The Client ID must start with the Provider ID, followed by a dot. It can then contain only upper case letters, numbers, and at most one hyphen.'
Expand Down
7 changes: 6 additions & 1 deletion app/models/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
symbol: [
validator('presence', true),
validator('unique-provider-id', true),
validator('unique-provider-id', {
presence: true,
disabled: Ember.computed('model', function() {
return !this.get('model').get('isNew');
})
}),
validator('format', {
regex: /^[A-Z]+$/,
message: 'The Provider ID can contain only upper case letters'
Expand Down
2 changes: 1 addition & 1 deletion app/validators/unique-provider-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const UniqueProviderId = BaseValidator.extend({
} else {
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. 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. Please contact DataCite staff if you want to create an account with this Provider ID.";
} else {
return true;
}
Expand Down

0 comments on commit 24fb574

Please sign in to comment.