Permalink
Browse files

feat(enumeration): define valid values for a field

  • Loading branch information...
bas080
bas080 committed Dec 23, 2016
1 parent 30d2fa1 commit aa204fc3077e34419e9de394a0f9bf92ecbab353
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/decorator/enumeration.js
@@ -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.