Commit 4cd7a78e authored by Sebastian Pekarek's avatar Sebastian Pekarek
Browse files

some small PR updates

parent ab746e4d
...@@ -429,7 +429,7 @@ Set the attendee's status. May be one of the following: accepted, tentative, dec ...@@ -429,7 +429,7 @@ Set the attendee's status. May be one of the following: accepted, tentative, dec
#### type([_String_ type]) #### type([_String_ type])
Set the attendee's type. May be one of the following: INDIVIDUAL', 'GROUP', 'RESOURCE', 'ROOM', 'UNKNOWN'], // // ref: https://tools.ietf.org/html/rfc2445#section-4.2.3 Set the attendee's type. May be one of the following: `INDIVIDUAL`, `GROUP`, `RESOURCE`, `ROOM`, `UNKNOWN` (See [Section 4.2.3](https://tools.ietf.org/html/rfc2445#section-4.2.3))
......
...@@ -19,7 +19,7 @@ var ICalAttendee = function(_data, event) { ...@@ -19,7 +19,7 @@ var ICalAttendee = function(_data, event) {
allowed: { allowed: {
role: ['REQ-PARTICIPANT', 'NON-PARTICIPANT'], role: ['REQ-PARTICIPANT', 'NON-PARTICIPANT'],
status: ['ACCEPTED', 'TENTATIVE', 'DECLINED', 'DELEGATED'], status: ['ACCEPTED', 'TENTATIVE', 'DECLINED', 'DELEGATED'],
type: ['INDIVIDUAL', 'GROUP', 'RESOURCE', 'ROOM', 'UNKNOWN'], // // ref: https://tools.ietf.org/html/rfc2445#section-4.2.3 type: ['INDIVIDUAL', 'GROUP', 'RESOURCE', 'ROOM', 'UNKNOWN'], // ref: https://tools.ietf.org/html/rfc2445#section-4.2.3
} }
}; };
...@@ -33,6 +33,34 @@ var ICalAttendee = function(_data, event) { ...@@ -33,6 +33,34 @@ var ICalAttendee = function(_data, event) {
delegatedFrom: null delegatedFrom: null
}; };
function getAllowedRole(str) {
return getAllowedStringFor('role', str);
}
function getAllowedStatus(str) {
return getAllowedStringFor('status', str);
}
function getAllowedType(str){
return getAllowedStringFor('type', str);
}
function getAllowedStringFor(type, str) {
if (!str || typeof(str) !== 'string') {
throw new Error('Input for `' + type + '` must be a non-empty string. You gave ' + str);
}
str = str.toUpperCase();
if (vars.allowed[type].indexOf(str) === -1) {
throw new Error('`' + type + '` must be one of the following: ' + vars.allowed[type].join(', ') + '!');
}
return str;
}
/** /**
* Set/Get the attendee's name * Set/Get the attendee's name
* *
...@@ -235,32 +263,6 @@ var ICalAttendee = function(_data, event) { ...@@ -235,32 +263,6 @@ var ICalAttendee = function(_data, event) {
this[i](_data[i]); this[i](_data[i]);
} }
} }
function getAllowedRole(str) {
return getAllowedStringFor('role', str);
}
function getAllowedStatus(str) {
return getAllowedStringFor('status', str);
}
function getAllowedType(str){
return getAllowedStringFor('type', str);
}
function getAllowedStringFor(type, str) {
if (!str || typeof(str) !== 'string') {
throw new Error('Input for `' + type + '` must be a non-empty string. You gave ' + str);
}
str = str.toUpperCase();
if (vars.allowed[type].indexOf(str) === -1) {
throw new Error('`' + type + '` must be one of the following: ' + vars.allowed[type].join(', ') + '!');
}
return str;
}
}; };
module.exports = ICalAttendee; module.exports = ICalAttendee;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "ical-generator", "name": "ical-generator",
"description": "ical-generator is a small piece of code which generates ical calendar files", "description": "ical-generator is a small piece of code which generates ical calendar files",
"author": "Sebastian Pekarek <mail@sebbo.net>", "author": "Sebastian Pekarek <mail@sebbo.net>",
"version": "0.2.2", "version": "0.2.3-dev",
"bugs": { "bugs": {
"url": "http://github.com/sebbo2002/ical-generator/issues", "url": "http://github.com/sebbo2002/ical-generator/issues",
"email": "bugs@sebbo.net" "email": "bugs@sebbo.net"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment