mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Add error checking directive and unit tests for it
This commit is contained in:
parent
d4654eb5cf
commit
0f14ad8ccf
5 changed files with 98 additions and 0 deletions
11
tests/_data/template/v2validation.executed.html
Normal file
11
tests/_data/template/v2validation.executed.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
<div class="alert">
|
||||
<p>You have an error!</p>
|
||||
<p><strong>[Ref. #2]</strong></p>
|
||||
</div>
|
||||
|
||||
<div class="alert">
|
||||
<p>You have an error!</p>
|
||||
<p><strong>[Ref. #4]</strong></p>
|
||||
</div>
|
||||
|
||||
41
tests/_data/template/v2validation.html
Normal file
41
tests/_data/template/v2validation.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
@version(2)
|
||||
|
||||
<!--// No error yet -->
|
||||
@error('foo/bar/baz/1')
|
||||
<div class="alert">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
<p><strong>[Ref. #1]</strong></p>
|
||||
</div>
|
||||
@enderror
|
||||
|
||||
<!--// We set error ID and message now -->
|
||||
{@ $XE_VALIDATOR_ID = 'foo/bar/baz/1'}
|
||||
{@ $XE_VALIDATOR_MESSAGE = 'You have an error!'}
|
||||
|
||||
<!--// This should work -->
|
||||
@error('foo/bar/baz/3', 'foo/bar/baz/2', 'foo/bar/baz/1')
|
||||
<div class="alert">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
<p><strong>[Ref. #2]</strong></p>
|
||||
</div>
|
||||
@enderror
|
||||
|
||||
<!--// Wrong error ID -->
|
||||
@error('foo/bar/baz/6', 'foo/bar/baz/5', 'foo/bar/baz/4')
|
||||
<div class="alert">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
<p><strong>[Ref. #3]</strong></p>
|
||||
</div>
|
||||
@enderror
|
||||
|
||||
<!--// Check for any error, this should also work -->
|
||||
@error
|
||||
<div class="alert">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
<p><strong>[Ref. #4]</strong></p>
|
||||
</div>
|
||||
@enderror
|
||||
|
||||
<!--// Cleanup -->
|
||||
{@ $XE_VALIDATOR_ID = null}
|
||||
{@ $XE_VALIDATOR_MESSAGE = null}
|
||||
Loading…
Add table
Add a link
Reference in a new issue