2727# ' @param allowed A list of allowed values
2828# ' @inheritParams entity
2929# ' @rdname enum
30- enum = function (name , description = character (0 ), type = ' character' ,
30+ enum = function (name , description = character (0 ), type = ' character' ,
3131 value = character (0 ),max_length = 1 ,allowed ,... ) {
32-
32+
3333 # new object
3434 out = .enum(
35- name = name ,
35+ name = name ,
3636 description = description ,
3737 type = type ,
3838 value = value ,
@@ -50,8 +50,8 @@ enum = function(name, description=character(0), type='character',
5050 prototype = list (name = ' name not provided' ,
5151 description = ' no description provided' ),
5252 validity = function (object ) {
53- check_list = object @ value %in% object @ allowed
54-
53+ check_list = (all( object @ value %in% object @ allowed ))
54+
5555 # check enum validity
5656 msg = TRUE
5757 if (! check_list ) {
@@ -70,7 +70,7 @@ enum = function(name, description=character(0), type='character',
7070setMethod(f = " value<-" ,
7171 signature = c(" enum" ),
7272 definition = function (obj ,value ) {
73- if (value %in% obj @ allowed ) {
73+ if (all( value %in% obj @ allowed ) ) {
7474 obj @ value = value
7575 } else {
7676 stop(value ,' is not a valid choice for this enum.' )
@@ -84,7 +84,7 @@ setMethod(f = 'show',
8484 signature = c(' enum' ),
8585 definition = function (object ) {
8686 callNextMethod()
87-
87+
8888 cat(' allowed: ' ,paste0(object @ allowed ,collapse = ' , ' ))
8989 cat(' \n ' )
9090 }
0 commit comments