BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
Try {
- if (argumentCount != 2)
+ if (argumentCount < 1 || argumentCount > 2)
ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
if (!JSValueIsString(gContext, arguments[0]))
ThrowMsg(InvalidArgumentException, "1st argument is not string.");
- if (!JSIsArrayValue(gContext, arguments[1]))
- ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
+ if (argumentCount >= 2)
+ {
+ if (!JSIsArrayValue(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
+ ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
+ }
} Catch(Exception ) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
std::string number;
- ContactPhoneNumberTypeArrayPtr types;
+ ContactPhoneNumberTypeArrayPtr types(NULL);
Try {
number = converter->toString(arguments[0]);
}
Try {
- types = converter->toContactPhoneNumberTypeArray(arguments[1]);
- if(types->size() == 0)
+ if(argumentCount >= 2)
+ {
+ if(JSIsArrayValue(gContext, arguments[1]))
+ types = converter->toContactPhoneNumberTypeArray(arguments[1]);
+ }
+ if(types == NULL)
+ {
+ types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
types->push_back(CONTACT_PHONE_NUMBER_TYPE_VOICE);
+ }
} Catch(Exception) {
LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
*exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");