Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Created July 17, 2011 02:30
Show Gist options
  • Select an option

  • Save TiuTalk/1087056 to your computer and use it in GitHub Desktop.

Select an option

Save TiuTalk/1087056 to your computer and use it in GitHub Desktop.
Criando um método de validação
<?php
class Usuario extends AppModel {
public $name = 'Usuario';
public $validate = array(
'twitter' => array(
'rule' => 'perfilTwitter',
'message' => 'Perfil do Twitter inválido'
)
);
public function perfilTwitter($data) {
$perfil = array_shift($data);
// Letras, números e _
$pattern = '/@([A-Za-z0-9_]+)/';
return preg_match($pattern, $perfil);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment