Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Shifted package

  • Loading branch information...
commit 255112d04b10675d8d740bde4c1b92a634a8d970 1 parent 947ea96
Daniel O'Connor CloCkWeRX authored
56 Validate/NO.php
... ... @@ -1,56 +0,0 @@
1   -<?php
2   -/* vim: set expandtab tabstop=4 shiftwidth=4: */
3   -/**
4   - * Methods for validation in Norway
5   - *
6   - * PHP Version 5
7   - *
8   - * This source file is subject to the New BSD license, That is bundled
9   - * with this package in the file LICENSE, and is available through
10   - * the world-wide-web at
11   - * http://www.opensource.org/licenses/bsd-license.php
12   - * If you did not receive a copy of the new BSDlicense and are unable
13   - * to obtain it through the world-wide-web, please send a note to
14   - * pajoye@php.net so we can mail you a copy immediately.
15   - *
16   - * @category Validate
17   - * @package Validate_NO
18   - * @author Christian Weiske <cweiske@php.net>
19   - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
20   - * @version SVN: $Id: DE.php 242590 2007-09-16 17:35:37Z kguest $
21   - * @link http://pear.php.net/package/Validate_DE
22   - */
23   -
24   -/**
25   - * Data validation class for Norway
26   - *
27   - * This class provides methods to validate:
28   - * - Postal code
29   - *
30   - * @category Validate
31   - * @package Validate_NO
32   - * @author Christian Weiske <cweiske@php.net>
33   - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
34   - * @version Release: @package_version@
35   - * @link http://pear.php.net/package/Validate_DE
36   - */
37   -class Validate_NO
38   -{
39   - /**
40   - * Validate a Norway postcode.
41   - *
42   - * @param string $postcode postcode to validate
43   - * @param bool $strong optional; strong checks (e.g. against a list of
44   - * postcodes) (not implemented)
45   - *
46   - * @return bool true if postcode is ok, false otherwise
47   - *
48   - * http://en.wikipedia.org/wiki/Postal_codes_in_Norway
49   - */
50   - public static function postalCode($postcode, $strong = false)
51   - {
52   - return (bool)preg_match('/^[0-9]{4}$/', $postcode);
53   - }
54   -
55   -}
56   -?>
81 package_NO.xml
... ... @@ -1,81 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<package packagerversion="1.6.1"
3   - version="2.0"
4   - xmlns="http://pear.php.net/dtd/package-2.0"
5   - xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
6   - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7   - xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"
8   ->
9   - <name>Validate_NO</name>
10   - <channel>pear.php.net</channel>
11   - <summary>Validation class for Norway</summary>
12   - <description>Package containes locale validation for Norway such as:
13   - * Postal Code
14   - </description>
15   -
16   - <lead>
17   - <name>Christian Weiske</name>
18   - <user>cweiske</user>
19   - <email>cweiske@php.net</email>
20   - <active>yes</active>
21   - </lead>
22   -
23   - <date>2010-08-04</date>
24   -
25   - <version>
26   - <release>0.1.0</release>
27   - <api>0.1.0</api>
28   - </version>
29   -
30   - <stability>
31   - <release>alpha</release>
32   - <api>alpha</api>
33   - </stability>
34   -
35   - <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD</license>
36   -
37   - <notes>
38   - - First version with postal code validation
39   - </notes>
40   - <contents>
41   - <dir name="/">
42   - <file name="Validate/NO.php" role="php">
43   - <tasks:replace from="@package_version@" to="version" type="package-info" />
44   - </file>
45   - <file name="tests/validate_NO_postalcodes.phpt" role="test" />
46   - </dir>
47   - </contents>
48   -
49   - <dependencies>
50   - <required>
51   - <php>
52   - <min>5.2.0</min>
53   - </php>
54   - <pearinstaller>
55   - <min>1.8.0</min>
56   - </pearinstaller>
57   - </required>
58   - </dependencies>
59   -
60   - <phprelease />
61   -
62   - <changelog>
63   -
64   - <release>
65   - <version>
66   - <release>0.1.0</release>
67   - <api>0.1.0</api>
68   - </version>
69   - <stability>
70   - <release>alpha</release>
71   - <api>alpha</api>
72   - </stability>
73   - <date>2010-08-04</date>
74   - <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD</license>
75   - <notes>
76   - - Initial release
77   - </notes>
78   - </release>
79   -
80   - </changelog>
81   -</package>
37 tests/validate_NO_postalcodes.phpt
... ... @@ -1,37 +0,0 @@
1   ---TEST--
2   -Test norway postal codes
3   ---FILE--
4   -<?php
5   -$noYes = array('NO', 'YES');
6   -if (is_file(dirname(__FILE__) . '/../Validate/NO.php')) {
7   - require_once dirname(__FILE__) . '/../Validate/NO.php';
8   -} else {
9   - require_once 'Validate/NO.php';
10   -}
11   -
12   -
13   -$postalCodes = array(
14   - 1234,//ok
15   - 9238,//ok
16   - 'a123',//no
17   - '923Z',//no
18   - 123,//no
19   - 12,//no
20   - 1,//no
21   -);
22   -
23   -foreach ($postalCodes as $postalCode) {
24   - echo "{$postalCode}: "
25   - . $noYes[
26   - Validate_NO::postalCode($postalCode)
27   - ] . "\n";
28   -}
29   -
30   ---EXPECT--
31   -1234: YES
32   -9238: YES
33   -a123: NO
34   -923Z: NO
35   -123: NO
36   -12: NO
37   -1: NO

0 comments on commit 255112d

Please sign in to comment.
Something went wrong with that request. Please try again.