Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
feat(enumeration): define valid values for a field
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Jan 4, 2017
1 parent 30d2fa1 commit aa204fc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/decorator/enumeration.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
import {OrmMetadata} from '../orm-metadata';
import {ensurePropertyIsConfigurable} from './utils';

/**
* Registers the 'enumerations' for an attribute's values
*
* @param {*[]} values - a list of valid values for the entity's attribute
*
* @return {Function}
*
* @decorator
*/
export function enumeration(values) {
return function(target, propertyName, descriptor) {
ensurePropertyIsConfigurable(target, propertyName, descriptor);

OrmMetadata.forTarget(target.constructor).put('enumerations', propertyName, values);
};
}

0 comments on commit aa204fc

Please sign in to comment.