Skip to content

Commit 7f41103

Browse files
committed
fix max_length bug
include max_length in protoype and add check in validity fcn
1 parent 8921c10 commit 7f41103

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

R/entity_class.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#'
3131
entity<-setClass(
3232
"entity",
33-
slots=c(value='ANY'),
33+
slots=c(value='ANY',max_length='numeric'),
3434
contains='struct_class',
3535
prototype=list(name='name not provided',
3636
description='no description provided',
@@ -41,14 +41,17 @@ entity<-setClass(
4141
validity = function(object) {
4242
check_length=length(value(object)) <= max_length(object)
4343
check_type=class(value(object))[1] %in% type(object)
44-
44+
check_max_length=length(max_length(object))==1
4545
msg=TRUE
4646
if (!check_length) {
4747
msg=paste0(name(object),': number of values must be less than "max_length"')
4848
}
4949
if (!check_type) {
5050
msg=paste0(name(object),': class of value must match "type"')
5151
}
52+
if (!check_max_length) {
53+
msg=paste0(name(object),': ', ' max_length must be of length 1')
54+
}
5255
return(msg)
5356
}
5457
)

0 commit comments

Comments
 (0)