Changeset 1939

Show
Ignore:
Timestamp:
02/05/2008 06:01:11 PM (10 months ago)
Author:
armen
Message:

Validation comments converted.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Validation.php

    r1911 r1939  
    4040 
    4141        /** 
    42          * Method: __construct 
    43          * 
    44          * Parameters: 
    45          *  data - array to validate 
     42         * @param array  array to validate 
    4643         */ 
    4744        public function __construct( & $data = array()) 
     
    5956 
    6057        /** 
    61          * Method: __get 
    62          *  Magically gets a validation variable. This can be an error string or a 
    63          *  data field, or an array of all field data. 
    64          * 
    65          * Parameters: 
    66          *  key - variable name 
    67          * 
    68          * Returns: 
    69          *  The variable contents or NULL if the variable does not exist 
     58         * Magically gets a validation variable. This can be an error string or a 
     59         * data field, or an array of all field data. 
     60         * 
     61         * @param   string        Variable name 
     62         * @return  string|array  The variable contents or NULL if the variable does not exist 
    7063         */ 
    7164        public function __get($key) 
     
    120113 
    121114        /** 
    122          * Method: set_rules 
    123          *  This function takes an array of key names, rules, and field names as 
    124          *  input and sets internal field information. 
    125          * 
    126          * Parameters: 
    127          *  data  - key names 
    128          *  rules - rules 
    129          *  field - field names 
     115         * This function takes an array of key names, rules, and field names as 
     116         * input and sets internal field information. 
     117         * 
     118         * @param   string|array Key names 
     119         * @param   string       Rules 
     120         * @param   string       Field name 
     121         * @return  void 
    130122         */ 
    131123        public function set_rules($data, $rules = '', $field = FALSE) 
     
    166158 
    167159        /** 
    168          * Method: set_message 
    169          *  Lets users set their own error messages on the fly. 
    170          *  Note - The key name has to match the function name that it corresponds to. 
    171          * 
    172          * Parameters: 
    173          *  func    - function name 
    174          *  message - error message 
     160         * Lets users set their own error messages on the fly. 
     161         * Note - The key name has to match the function name that it corresponds to. 
     162         * 
     163         * @param   string  Function name 
     164         * @param   string  Error message 
     165         * @return  void 
    175166         */ 
    176167        public function set_message($func, $message = '') 
     
    188179 
    189180        /** 
    190          * Method: set_data 
    191          * 
    192          * Parameters: 
    193          *  data - array to validate 
     181         * @param   array  Data to validate 
     182         * @return  void 
    194183         */ 
    195184        public function set_data( & $data) 
     
    206195 
    207196        /** 
    208          * Method: error_format 
    209          *  Allows the user to change the error message format. Error formats must 
    210          *  contain the string "{message}" or Kohana_Exception will be triggered. 
    211          * 
    212          * Parameters: 
    213          *  string - error message 
     197         * Allows the user to change the error message format. Error formats must 
     198         * contain the string "{message}" or Kohana_Exception will be triggered. 
     199         * 
     200         * @param   string  Error message format   
     201         * @return  void 
    214202         */ 
    215203        public function error_format($string = '') 
     
    222210 
    223211        /** 
    224          * Method: add_error 
    225          * 
    226          * Parameters: 
    227          *  func  - function name 
    228          *  field - field name 
     212         * @param   string  Function name 
     213         * @param   string  field name 
     214         * @return  void 
    229215         */ 
    230216        public function add_error($func, $field) 
     
    252238 
    253239        /** 
    254          * Method: run 
    255          *  This function does all the work. 
    256          * 
    257          * Returns: 
    258          *  TRUE or FALSE 
     240         * This function does all the work. 
     241         * 
     242         * @return  boolean  The validation result 
    259243         */ 
    260244        public function run() 
     
    329313 
    330314        /** 
    331          * Method: run_rule 
    332          *  Handles recursively calling rules on arrays of data. 
    333          * 
    334          * Parameters: 
    335          *  rule  - validation rule to be run on the data 
    336          *  field - name of field 
     315         * Handles recursively calling rules on arrays of data. 
     316         * 
     317         * @param   string  Validation rule to be run on the data 
     318         * @param   string  Name of field 
     319         * @return  void 
    337320         */ 
    338321        protected function run_rule($rule, $field) 
     
    414397 
    415398        /** 
    416          * Method: in_array 
     399         * @param   mixed 
     400         * @param   array 
     401         * @return  boolean 
    417402         */ 
    418403        public function in_array($data, $array = FALSE) 
     
    428413 
    429414        /** 
    430          * Method: event 
     415         * @param   mixed         Data to pass to the event 
     416         * @param   array         Events name 
     417         * @return  boolean|void 
    431418         */ 
    432419        public function event($data, $events = FALSE) 
     
    447434 
    448435        /** 
    449          * Method: upload 
     436         * @param   array 
     437         * @param   array 
     438         * @return  boolean|void 
    450439         */ 
    451440        public function upload($data, $params = FALSE) 
     
    710699 
    711700        /** 
    712          * Method: required 
    713          * 
    714          * Parameters: 
    715          *  str    - string to validate 
    716          *  length - 
    717          * 
    718          * Returns: 
    719          *  TRUE or FALSE 
     701         * @param   string  String to check 
     702         * @param   array   Length 
     703         * @return  boolean 
    720704         */ 
    721705        public function required($str, $length = FALSE) 
     
    763747 
    764748        /** 
    765          * Method: matches 
    766          *  Match one field to another. 
    767          * 
    768          * Parameters: 
    769          *  field - first field 
    770          *  match - field to match to first 
    771          * 
    772          * Returns: 
    773          *  TRUE or FALSE 
     749         * Match one field to another. 
     750         * 
     751         * @param   string  First field 
     752         * @param   string  Field to match to first 
     753         * @return  boolean 
    774754         */ 
    775755        public function matches($field, $match) 
     
    790770 
    791771        /** 
    792          * Method: min_length 
    793          *  Check a string for a minimum length. 
    794          * 
    795          * Parameters: 
    796          *  str - string to validate 
    797          *  val - minimum length 
    798          * 
    799          * Returns: 
    800          *  TRUE or FALSE 
     772         * Check a string for a minimum length. 
     773         * 
     774         * @param   string   String to validate 
     775         * @param   integer  Minimum length 
     776         * @return  boolean 
    801777         */ 
    802778        public function min_length($str, $val) 
     
    815791 
    816792        /** 
    817          * Method: max_length 
    818          *  Check a string for a maximum length. 
    819          * 
    820          * Parameters: 
    821          *  str - string to validate 
    822          *  val - maximum length 
    823          * 
    824          * Returns: 
    825          *  TRUE or FALSE 
     793         * Check a string for a maximum length. 
     794         * 
     795         * @param   string   String to validate 
     796         * @param   integer  Maximum length 
     797         * @return  boolean 
    826798         */ 
    827799        public function max_length($str, $val) 
     
    840812 
    841813        /** 
    842          * Method: exact_length 
    843          *  Check a string for an exact length. 
    844          * 
    845          * Parameters: 
    846          *  str - string to validate 
    847          *  val - length 
    848          * 
    849          * Returns: 
    850          *  TRUE or FALSE 
     814         * Check a string for an exact length. 
     815         * 
     816         * @param   string   String to validate 
     817         * @param   integer  Length 
     818         * @return  boolean 
    851819         */ 
    852820        public function exact_length($str, $val) 
     
    865833 
    866834        /** 
    867          * Method: valid_url 
    868          *  Valid URL. 
    869          * 
    870          * Parameters: 
    871          *  url    - URL 
    872          *  scheme - protocol 
    873          * 
    874          * Returns: 
    875          *  TRUE or FALSE 
     835         * Validate URL. 
     836         * 
     837         * @param   string  URL 
     838         * @param   string  Scheme 
     839         * @return  boolean 
    876840         */ 
    877841        public function valid_url($url, $scheme = '') 
     
    895859 
    896860        /** 
    897          * Method: valid_email 
    898          *  Valid Email, Commonly used characters only. 
    899          * 
    900          * Parameters: 
    901          *  email - email address 
    902          * 
    903          * Returns: 
    904          *  TRUE or FALSE 
     861         * Valid Email, Commonly used characters only. 
     862         * 
     863         * @param   string  Email address 
     864         * @return  boolean 
    905865         */ 
    906866        public function valid_email($email) 
     
    914874 
    915875        /** 
    916          * Method: valid_email_rfc 
    917          *  Valid Email, RFC compliant version 
    918          * 
    919          * Parameters: 
    920          *  email - email address 
    921          * 
    922          * Returns: 
    923          *  TRUE or FALSE 
     876         * Valid Email, RFC compliant version 
     877         * 
     878         * @param   string  Email address 
     879         * @return  boolean 
    924880         */ 
    925881        public function valid_email_rfc($email) 
     
    933889 
    934890        /** 
    935          * Method: valid_ip 
    936          *  Validate IP Address. 
    937          * 
    938          * Parameters: 
    939          *  ip - ip address 
    940          * 
    941          * Returns: 
    942          *  TRUE or FALSE 
     891         * Validate IP Address. 
     892         * 
     893         * @param   string  IP address 
     894         * @return  boolean 
    943895         */ 
    944896        public function valid_ip($ip) 
     
    952904 
    953905        /** 
    954          * Method: alpha 
    955          *  Alphabetic characters only. 
    956          * 
    957          * Parameters: 
    958          *  str - string to validate 
    959          * 
    960          * Returns: 
    961          *  TRUE or FALSE 
     906         * Alphabetic characters only. 
     907         * 
     908         * @param   string  String to validate 
     909         * @return  boolean 
    962910         */ 
    963911        public function alpha($str) 
     
    971919 
    972920        /** 
    973          * Method: utf8_alpha 
    974          *  Alphabetic characters only (UTF-8 compatible). 
    975          * 
    976          * Parameters: 
    977          *  str - string to validate 
    978          * 
    979          * Returns: 
    980          *  TRUE or FALSE 
     921         * Alphabetic characters only (UTF-8 compatible). 
     922         * 
     923         * @param   string  String to validate 
     924         * @return  boolean 
    981925         */ 
    982926        public function utf8_alpha($str) 
     
    990934 
    991935        /** 
    992          * Method: alpha_numeric 
    993          *  Alphabetic and numeric characters only. 
    994          * 
    995          * Parameters: 
    996          *  str - string to validate 
    997          * 
    998          * Returns: 
    999          *  TRUE or FALSE 
     936         * Alphabetic and numeric characters only. 
     937         * 
     938         * @param   string  String to validate 
     939         * @return  boolean 
    1000940         */ 
    1001941        public function alpha_numeric($str) 
     
    1009949 
    1010950        /** 
    1011          * Method: utf8_alpha_numeric 
    1012          *  Alphabetic and numeric characters only (UTF-8 compatible). 
    1013          * 
    1014          * Parameters: 
    1015          *  str - string to validate 
    1016          * 
    1017          * Returns: 
    1018          *  TRUE or FALSE 
     951         * Alphabetic and numeric characters only (UTF-8 compatible). 
     952         * 
     953         * @param   string  String to validate 
     954         * @return  boolean 
    1019955         */ 
    1020956        public function utf8_alpha_numeric($str) 
     
    1028964 
    1029965        /** 
    1030          * Method: alpha_dash 
    1031          *  Alpha-numeric with underscores and dashes. 
    1032          * 
    1033          * Parameters: 
    1034          *  str - string to validate 
    1035          * 
    1036          * Returns: 
    1037          *  TRUE or FALSE 
     966         * Alpha-numeric with underscores and dashes. 
     967         * 
     968         * @param   string  String to validate 
     969         * @return  boolean 
    1038970         */ 
    1039971        public function alpha_dash($str) 
     
    1047979 
    1048980        /** 
    1049          * Method: utf8_alpha_dash 
    1050          *  Alpha-numeric with underscores and dashes (UTF-8 compatible). 
    1051          * 
    1052          * Parameters: 
    1053          *  str - string to validate 
    1054          * 
    1055          * Returns: 
    1056          *  TRUE or FALSE 
     981         * Alpha-numeric with underscores and dashes (UTF-8 compatible). 
     982         * 
     983         * @param   string  String to validate 
     984         * @return  boolean 
    1057985         */ 
    1058986        public function utf8_alpha_dash($str) 
     
    1066994 
    1067995        /** 
    1068          * Method: digit 
    1069          *  Digits 0-9, no dots or dashes. 
    1070          * 
    1071          * Parameters: 
    1072          *  str - string to validate 
    1073          * 
    1074          * Returns: 
    1075          *  TRUE or FALSE 
     996         * Digits 0-9, no dots or dashes. 
     997         * 
     998         * @param   string  String to validate 
     999         * @return  boolean 
    10761000         */ 
    10771001        public function digit($str) 
     
    10851009 
    10861010        /** 
    1087          * Method: utf8_digit 
    1088          *  Digits 0-9, no dots or dashes (UTF-8 compatible). 
    1089          * 
    1090          * Parameters: 
    1091          *  str - string to validate 
    1092          * 
    1093          * Returns: 
    1094          *  TRUE or FALSE 
     1011         * Digits 0-9, no dots or dashes (UTF-8 compatible). 
     1012         * 
     1013         * @param   string  String to validate 
     1014         * @return  boolean 
    10951015         */ 
    10961016        public function utf8_digit($str) 
     
    11041024 
    11051025        /** 
    1106          * Method: numeric 
    1107          *  Digits 0-9 (negative and decimal numbers allowed). 
    1108          * 
    1109          * Parameters: 
    1110          *  str - string to validate 
    1111          * 
    1112          * Returns: 
    1113          *  TRUE or FALSE 
     1026         * Digits 0-9 (negative and decimal numbers allowed). 
     1027         * 
     1028         * @param   string  String to validate 
     1029         * @return  boolean 
    11141030         */ 
    11151031        public function numeric($str) 
     
    11231039 
    11241040        /** 
    1125          * Method: range 
    1126          *  Test that a field is between a range. 
    1127          * 
    1128          * Parameters: 
    1129          *  num    - number to validate 
    1130          *  ranges - ranges 
    1131          * 
    1132          * Returns: 
    1133          *  TRUE or FALSE 
     1041         * Test that a field is between a range. 
     1042         * 
     1043         * @param   integer  Number to validate 
     1044         * @param   array    Renges 
     1045         * @return  boolean 
    11341046         */ 
    11351047        public function range($num, $ranges) 
     
    11601072 
    11611073        /** 
    1162          * Method: depends_on 
    1163          * 
    1164          * Parameters: 
    1165          *  field      - first field 
    1166          *  depends_on - field which the first field is depend on it 
    1167          * 
    1168          * Returns: 
    1169          *  TRUE or FALSE 
     1074         * Check dependency between fields. 
     1075         *  
     1076         * @param   string  First field 
     1077         * @param   string  Field which the first field is depend on it 
     1078         * @return  boolean 
    11701079         */ 
    11711080        public function depends_on($field, $depends_on) 
     
    11851094 
    11861095        /** 
    1187          * Method: regex 
    1188          *  Test a field against a regex rule 
    1189          * 
    1190          * Parameters: 
    1191          *  str   - string to test 
    1192          *  regex - regular expression to run 
    1193          * 
    1194          * Returns: 
    1195          *  TRUE or FALSE 
     1096         * Test a field against a regex rule 
     1097         * 
     1098         * @param   string  String to test 
     1099         * @param   string  Regular expression to run 
     1100         * @return  boolean 
    11961101         */ 
    11971102        public function regex($str, $regex) 
     
    12141119 
    12151120        /** 
    1216          * Method: prep_for_form 
    1217          *  This function allows HTML to be safely shown in a form. 
    1218          *  Special characters are converted. 
    1219          * 
    1220          * Parameters: 
    1221          *  str - HTML 
    1222          * 
    1223          * Returns: 
    1224          *  Prepped HTML 
     1121         * This function allows HTML to be safely shown in a form. 
     1122         * Special characters are converted. 
     1123         * 
     1124         * @param   string  HTML 
     1125         * @return  string  Prepped HTML 
    12251126         */ 
    12261127        public function prep_for_form($str = '') 
     
    12331134 
    12341135        /** 
    1235          * Method: prep_url 
    1236          * 
    1237          * Parameters: 
    1238          *  str - URL 
     1136         * @param   string  URL 
     1137         * @return  void 
    12391138         */ 
    12401139        public function prep_url($str = '') 
     
    12551154 
    12561155        /** 
    1257          * Method: strip_image_tags 
    1258          *  Strip image tags from string. 
    1259          * 
    1260          * Parameters: 
    1261          *  str - string 
     1156         * Strip image tags from string. 
     1157         * 
     1158         * @param   string  HTML 
     1159         * @return  void 
    12621160         */ 
    12631161        public function strip_image_tags($str) 
     
    12671165 
    12681166        /** 
    1269          * Method: xss_clean 
    1270          *  XSS clean string. 
    1271          * 
    1272          * Parameters: 
    1273          *  str - string 
     1167         * XSS clean string. 
     1168         * 
     1169         * @param   string  String to be clean 
     1170         * @return  void 
    12741171         */ 
    12751172        public function xss_clean($str) 
     
    12791176 
    12801177        /** 
    1281          * Method: encode_php_tags 
    1282          *  Convert PHP tags to entities. 
    1283          * 
    1284          * Parameters: 
    1285          *  str - string 
     1178         * Convert PHP tags to entities. 
     1179         * 
     1180         * @param   string 
     1181         * @return  void 
    12861182         */ 
    12871183        public function encode_php_tags($str)