Um conversor de cliente personalizado ou validador pode ser implementado facilmente. Ambos são suportados.
$render = '';
$resposta = '';
DinarteCoelho.validator['custom.emailValidator'] = {
pattern: /^[a-z0-9.]+@[a-z0-9]+\.([a-z]+)?$/i,
validate: function (element, value) {
if (!this.pattern.test(value)) {
throw {
summary: 'Erro de Validação'
, detail: value + ' não é um e-mail válido.'
, severity: 'error'
}
}
}
};
DinarteCoelho.validator['Email'] = {
pattern: /\S+@\S+/,
MESSAGE_ID: 'br.com.dinartecoelho.examples.validate.email.message',
validate: function (element, value) {
var vc = DinarteCoelho.validation.ValidationContext;
if (!this.pattern.test(value)) {
var msgStr = element.data('p-email-msg')
, msg = msgStr ? {
summary: 'Erro de validação',
detail: msgStr,
severity: 'error'
} : vc.getMessage(this.MESSAGE_ID);
throw msg;
}
}
};
dc.cw("Growl", "widget_alerta", {
id: "alerta"
, sticky: false
, life: 6000
, escape: true
, keepAlive: false
, msgs: []
});
dc.cw("InputText", "widget_email1", {
id: "email1"
});
dc.cw("Message", "widget_alerta_email1", {
id: "alerta:email1"
, target: "email1"
, tooltip: true
});
dc.cw("InputText", "widget_email2", {
id: "email2"
});
dc.cw("Message", "widget_alerta_email2", {
id: "alerta:email2"
, target: "email2"
, tooltip: true
});