gboolean ret;
gboolean ret_callback;
- gchar *value;
+ GValue *value;
guint i;
ZakFormElementPrivate *priv;
}
else
{
- value = zak_form_element_get_value (element);
+ value = zak_form_element_get_value_gvalue (element);
for (i = 0; i < priv->pa_validators->len; i++)
{
}
gboolean
-zak_form_element_validator_validate (ZakFormElementValidator *self, const gchar *value)
+zak_form_element_validator_validate (ZakFormElementValidator *self, GValue *value)
{
gboolean ret;
GObjectClass parent_class;
gboolean (*xml_parsing) (ZakFormElementValidator *self, xmlNode *xnode);
- gboolean (*validate) (ZakFormElementValidator *self, const gchar *value);
+ gboolean (*validate) (ZakFormElementValidator *self, GValue *value);
void (*get_xml) (ZakFormElementValidator *self, xmlNode *xnode, const gchar *version);
};
gboolean zak_form_element_validator_xml_parsing (ZakFormElementValidator *self, xmlNode *xnode);
-gboolean zak_form_element_validator_validate (ZakFormElementValidator *self, const gchar *value);
+gboolean zak_form_element_validator_validate (ZakFormElementValidator *self, GValue *value);
void zak_form_element_validator_set_id (ZakFormElementValidator *validator,
const gchar *id);
static void zak_form_element_validator_date_finalize (GObject *gobject);
static gboolean zak_form_element_validator_date_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
-static gboolean zak_form_element_validator_date_validate (ZakFormElementValidator *validator_date, const gchar *value);
+static gboolean zak_form_element_validator_date_validate (ZakFormElementValidator *validator_date, GValue *value);
static void zak_form_element_validator_date_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorDate
static gboolean
zak_form_element_validator_date_validate (ZakFormElementValidator *validator_date,
- const gchar *value)
+ GValue *value)
{
gboolean ret;
gchar *_value;
ZakFormElementValidatorDatePrivate *priv = zak_form_element_validator_date_get_instance_private (ZAK_FORM_ELEMENT_VALIDATOR_DATE (validator_date));
g_return_val_if_fail (value != NULL, FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS_STRING (value), FALSE);
gdt = NULL;
gdt_compare = NULL;
- _value = g_strstrip (g_strdup (value));
+ _value = g_strstrip (g_strdup (g_value_get_string (value)));
if (g_strcmp0 (_value, "") == 0)
{
ret = TRUE;
static void zak_form_element_validator_is_number_finalize (GObject *gobject);
static gboolean zak_form_element_validator_is_number_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
-static gboolean zak_form_element_validator_is_number_validate (ZakFormElementValidator *validator_is_number, const gchar *value);
+static gboolean zak_form_element_validator_is_number_validate (ZakFormElementValidator *validator_is_number, GValue *value);
static void zak_form_element_validator_is_number_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorIsNumber
static gboolean
zak_form_element_validator_is_number_validate (ZakFormElementValidator *validator_is_number,
- const gchar *value)
+ GValue *value)
{
gchar *_value;
ZakFormElementValidatorIsNumberPrivate *priv = zak_form_element_validator_is_number_get_instance_private (ZAK_FORM_ELEMENT_VALIDATOR_IS_NUMBER (validator_is_number));
g_return_val_if_fail (value != NULL, FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS_STRING (value), FALSE);
- _value = g_strstrip (g_strdup (value));
+ _value = g_strstrip (g_strdup (g_value_get_string (value)));
validator = zak_form_element_validator_regex_new ();
regex = g_string_new ("^");
g_string_free (regex, TRUE);
- return zak_form_element_validator_validate (ZAK_FORM_ELEMENT_VALIDATOR (validator), _value);
+ return zak_form_element_validator_validate (ZAK_FORM_ELEMENT_VALIDATOR (validator), zak_utils_gvalue_new_string (_value));
}
static void
static void zak_form_element_validator_notempty_finalize (GObject *gobject);
static gboolean zak_form_element_validator_notempty_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
-static gboolean zak_form_element_validator_notempty_validate (ZakFormElementValidator *validator_notempty, const gchar *value);
+static gboolean zak_form_element_validator_notempty_validate (ZakFormElementValidator *validator_notempty, GValue *value);
static void zak_form_element_validator_notempty_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorNotempty
static gboolean
zak_form_element_validator_notempty_validate (ZakFormElementValidator *validator,
- const gchar *value)
+ GValue *value)
{
gboolean ret;
g_return_val_if_fail (value != NULL, FALSE);
- ret = (g_strcmp0 (value, priv->as_empty_string) != 0);
+ ret = (g_strcmp0 (g_value_get_string (value), priv->as_empty_string) != 0);
return ret;
}
static void zak_form_element_validator_number_finalize (GObject *gobject);
static gboolean zak_form_element_validator_number_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
-static gboolean zak_form_element_validator_number_validate (ZakFormElementValidator *validator_number, const gchar *value);
+static gboolean zak_form_element_validator_number_validate (ZakFormElementValidator *validator_number, GValue *value);
static void zak_form_element_validator_number_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorNumber
static gboolean
zak_form_element_validator_number_validate (ZakFormElementValidator *validator_number,
- const gchar *value)
+ GValue *value)
{
gboolean ret;
g_return_val_if_fail (value != NULL, FALSE);
- _value = g_strtod (value, NULL);
+ _value = g_strtod (g_value_get_string (value), NULL);
if (_value < priv->compare_value)
{
static void zak_form_element_validator_regex_finalize (GObject *gobject);
static gboolean zak_form_element_validator_regex_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
-static gboolean zak_form_element_validator_regex_validate (ZakFormElementValidator *validator_regex, const gchar *value);
+static gboolean zak_form_element_validator_regex_validate (ZakFormElementValidator *validator_regex, GValue *value);
static void zak_form_element_validator_regex_get_xml (ZakFormElementValidator *validator, xmlNode *xnode, const gchar *version);
struct _ZakFormElementValidatorRegex
static gboolean
zak_form_element_validator_regex_validate (ZakFormElementValidator *validator_regex,
- const gchar *value)
+ GValue *value)
{
gboolean ret;
GError *error;
g_return_val_if_fail (value != NULL, FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS_STRING (value), FALSE);
ZakFormElementValidatorRegexPrivate *priv = zak_form_element_validator_regex_get_instance_private (ZAK_FORM_ELEMENT_VALIDATOR_REGEX (validator_regex));
|| error != NULL)
{
g_warning ("Error on creating regex: %s.",
- error->message != NULL ? error->message : "no details");
+ error->message != NULL ? error->message : "no details");
return FALSE;
}
- ret = g_regex_match ((const GRegex *)regex, value, 0, NULL);
+ ret = g_regex_match ((const GRegex *)regex, g_value_get_string (value), 0, NULL);
if (!ret)
{
- g_warning ("Value «%s» not valid for regex «%s».", value, priv->regex);
+ g_warning ("Value «%s» not valid for regex «%s».", g_value_get_string (value), priv->regex);
}
return ret;
else
{
if (zak_form_element_validator_validate (n_child->element_validator,
- zak_form_element_get_value (n_child->element)) == n_child->condition_type)
+ zak_form_element_get_value_gvalue (n_child->element)) == n_child->condition_type)
{
switch (n->logic_type)
{
else
{
ret = (ret && zak_form_element_validator_validate (n_child->element_validator,
- zak_form_element_get_value (n_child->element)));
+ zak_form_element_get_value_gvalue (n_child->element)));
}
}
break;
else
{
ret = (ret || zak_form_element_validator_validate (n_child->element_validator,
- zak_form_element_get_value (n_child->element)));
+ zak_form_element_get_value_gvalue (n_child->element)));
}
}
break;