<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FlexDev &#187; Validadores</title>
	<atom:link href="http://www.flexdev.com.br/home/tag/validadores/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flexdev.com.br/home</link>
	<description>Flex/AIR, Java e RIA em geral.</description>
	<lastBuildDate>Sat, 04 Sep 2010 13:01:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Validators ( Validadores )</title>
		<link>http://www.flexdev.com.br/home/validators-validadores/</link>
		<comments>http://www.flexdev.com.br/home/validators-validadores/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 04:59:53 +0000</pubDate>
		<dc:creator>Ebercom</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Divas]]></category>
		<category><![CDATA[Validadores]]></category>
		<category><![CDATA[Validators]]></category>

		<guid isPermaLink="false">http://blog.flexdev.com.br/validators-validadores/</guid>
		<description><![CDATA[Pessoal... Mais uma dica ai pra voces, dessa vez vamos fazer falar de um assunto que deve interessar a muitos dos desenvolvedores Flex, porque só existe uma maneira do usuário não errar: você não deixando ele fazer isso... hehe Brincadeiras a parte vamos lá, vou demonstrar o uso simples de dois componentes validadores: o EmailValidator [...]]]></description>
			<content:encoded><![CDATA[<p>Pessoal...</p>
<p>Mais uma dica ai pra voces, dessa vez vamos fazer falar de um assunto que deve interessar a muitos dos desenvolvedores Flex, porque só existe uma maneira do usuário não errar: você não deixando ele fazer isso... hehe</p>
<p>Brincadeiras a parte vamos lá, vou demonstrar o uso simples de dois componentes validadores: o  <a href="http://livedocs.adobe.com/flex/2/langref/mx/validators/EmailValidator.html" target="_blank">EmailValidator</a> e o <a href="http://livedocs.adobe.com/flex/2/langref/mx/validators/StringValidator.html" target="_blank">StringValidator</a> porém existem outros 16 <a href="http://livedocs.adobe.com/flex/2/langref/mx/validators/package-detail.html" target="_blank">validadores</a> presentes no Flex 2. Vou desenvolver um exemplo prático onde tenho uma aplicação que requer o login que no caso é o e-mail do usuário e a senha que não pode conter menos de 4 caracteres e nem mais de 10.  Vamos lá...</p>
<p>Primeiramente vou criar o visual necessário para aplicação.</p>
<div class="igBar"><span id="lxml-3"><a href="#" onclick="javascript:showPlainTxt('xml-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-3">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:application xmlns:<span style="color: #000066;">mx</span>=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">"absolute"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"302"</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"150"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:label <span style="color: #000066;">x</span>=<span style="color: #ff0000;">"17"</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">"38"</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">"Usuário"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:label <span style="color: #000066;">x</span>=<span style="color: #ff0000;">"17"</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">"68"</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">"Senha"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:textinput <span style="color: #000066;">x</span>=<span style="color: #ff0000;">"72"</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">"36"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"199"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"usuario"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:textinput <span style="color: #000066;">x</span>=<span style="color: #ff0000;">"72"</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">"66"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"199"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"senha"</span> <span style="color: #000066;">displayaspassword</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:button <span style="color: #000066;">x</span>=<span style="color: #ff0000;">"206"</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">"96"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Validar"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"btnValidar"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx</span>:button<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></mx:textinput></mx:textinput></mx:label></mx:label></mx:application></p>
<p>Agora vamos criar os validadores com suas respectivas regras.</p>
<div class="igBar"><span id="lxml-4"><a href="#" onclick="javascript:showPlainTxt('xml-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-4">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:emailvalidator <span style="color: #000066;">source</span>=<span style="color: #ff0000;">"{ usuario }"</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">trigger=&quot;{ btnValidar }&quot; triggerEvent=&quot;click&quot;/<span style="color: #ddbb00;">&amp;gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:stringvalidator <span style="color: #000066;">source</span>=<span style="color: #ff0000;">"{ senha }"</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">minLength=&quot;4&quot; maxLength=&quot;10&quot; trigger=&quot;{ btnValidar }&quot; triggerEvent=&quot;click&quot;/<span style="color: #ddbb00;">&amp;gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></mx:stringvalidator></mx:emailvalidator></p>
<p>Existem várias outras regras que podem ser adicionadas, para conhecer as opções de cada componente voces podem acessar os links que passei acima, onde está a documentação oficial de cada um deles, apesar de ser em inglês mesmo quem não domina ( como eu ) pode entender legal.</p>
<p>Para quem quiser conferir como ficou o exemplo clique <a href="http://www.flexdev.com.br/progs/validadores/bin/">aqui</a>.<br />
Para dar uma olhada no codigo fonte completo pode clicar <a href="http://www.flexdev.com.br/progs/validadores/Validadores.mxml">aqui</a>.</p>
<p>Não sei se notaram mas eu não me ative a personalizar as mensagens, até mesmo porque eu utilizei da tecnica aqui mesmo explicada num post anterior para poder traduzir toda a aplicação, mas quem quiser pode estar personalizando essas mensagens de erro.</p>
<p>Bom pessoal é isso ai gostaria de um FeedBack de voces ai se a maneira a qual eu estou expondo as dicas está legal, ou se poderia ser mais bem explicada, com mais exemplos ou sei lá...</p>
<p>Abraços...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flexdev.com.br/home/validators-validadores/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
