Changeset 1939 for trunk/system/libraries/Validation.php
- Timestamp:
- 02/05/2008 06:01:11 PM (11 months ago)
- Files:
-
- 1 modified
-
trunk/system/libraries/Validation.php (modified) (38 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/Validation.php
r1911 r1939 40 40 41 41 /** 42 * Method: __construct 43 * 44 * Parameters: 45 * data - array to validate 42 * @param array array to validate 46 43 */ 47 44 public function __construct( & $data = array()) … … 59 56 60 57 /** 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 70 63 */ 71 64 public function __get($key) … … 120 113 121 114 /** 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 130 122 */ 131 123 public function set_rules($data, $rules = '', $field = FALSE) … … 166 158 167 159 /** 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 175 166 */ 176 167 public function set_message($func, $message = '') … … 188 179 189 180 /** 190 * Method: set_data 191 * 192 * Parameters: 193 * data - array to validate 181 * @param array Data to validate 182 * @return void 194 183 */ 195 184 public function set_data( & $data) … … 206 195 207 196 /** 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 214 202 */ 215 203 public function error_format($string = '') … … 222 210 223 211 /** 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 229 215 */ 230 216 public function add_error($func, $field) … … 252 238 253 239 /** 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 259 243 */ 260 244 public function run() … … 329 313 330 314 /** 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 337 320 */ 338 321 protected function run_rule($rule, $field) … … 414 397 415 398 /** 416 * Method: in_array 399 * @param mixed 400 * @param array 401 * @return boolean 417 402 */ 418 403 public function in_array($data, $array = FALSE) … … 428 413 429 414 /** 430 * Method: event 415 * @param mixed Data to pass to the event 416 * @param array Events name 417 * @return boolean|void 431 418 */ 432 419 public function event($data, $events = FALSE) … … 447 434 448 435 /** 449 * Method: upload 436 * @param array 437 * @param array 438 * @return boolean|void 450 439 */ 451 440 public function upload($data, $params = FALSE) … … 710 699 711 700 /** 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 720 704 */ 721 705 public function required($str, $length = FALSE) … … 763 747 764 748 /** 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 774 754 */ 775 755 public function matches($field, $match) … … 790 770 791 771 /** 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 801 777 */ 802 778 public function min_length($str, $val) … … 815 791 816 792 /** 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 826 798 */ 827 799 public function max_length($str, $val) … … 840 812 841 813 /** 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 851 819 */ 852 820 public function exact_length($str, $val) … … 865 833 866 834 /** 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 876 840 */ 877 841 public function valid_url($url, $scheme = '') … … 895 859 896 860 /** 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 905 865 */ 906 866 public function valid_email($email) … … 914 874 915 875 /** 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 924 880 */ 925 881 public function valid_email_rfc($email) … … 933 889 934 890 /** 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 943 895 */ 944 896 public function valid_ip($ip) … … 952 904 953 905 /** 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 962 910 */ 963 911 public function alpha($str) … … 971 919 972 920 /** 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 981 925 */ 982 926 public function utf8_alpha($str) … … 990 934 991 935 /** 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 1000 940 */ 1001 941 public function alpha_numeric($str) … … 1009 949 1010 950 /** 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 1019 955 */ 1020 956 public function utf8_alpha_numeric($str) … … 1028 964 1029 965 /** 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 1038 970 */ 1039 971 public function alpha_dash($str) … … 1047 979 1048 980 /** 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 1057 985 */ 1058 986 public function utf8_alpha_dash($str) … … 1066 994 1067 995 /** 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 1076 1000 */ 1077 1001 public function digit($str) … … 1085 1009 1086 1010 /** 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 1095 1015 */ 1096 1016 public function utf8_digit($str) … … 1104 1024 1105 1025 /** 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 1114 1030 */ 1115 1031 public function numeric($str) … … 1123 1039 1124 1040 /** 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 1134 1046 */ 1135 1047 public function range($num, $ranges) … … 1160 1072 1161 1073 /** 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 1170 1079 */ 1171 1080 public function depends_on($field, $depends_on) … … 1185 1094 1186 1095 /** 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 1196 1101 */ 1197 1102 public function regex($str, $regex) … … 1214 1119 1215 1120 /** 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 1225 1126 */ 1226 1127 public function prep_for_form($str = '') … … 1233 1134 1234 1135 /** 1235 * Method: prep_url 1236 * 1237 * Parameters: 1238 * str - URL 1136 * @param string URL 1137 * @return void 1239 1138 */ 1240 1139 public function prep_url($str = '') … … 1255 1154 1256 1155 /** 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 1262 1160 */ 1263 1161 public function strip_image_tags($str) … … 1267 1165 1268 1166 /** 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 1274 1171 */ 1275 1172 public function xss_clean($str) … … 1279 1176 1280 1177 /** 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 1286 1182 */ 1287 1183 public function encode_php_tags($str)
