country¶
validators.country.calling_code(value)
¶
Validates given calling code.
This performs country's calling code validation.
Examples:
>>> calling_code('+91')
# Output: True
>>> calling_code('-31')
# Output: ValidationError(func=calling_code, args={'value': '-31'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Country's calling code string to validate. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/country.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
validators.country.country_code(value, /, *, iso_format='auto', ignore_case=False)
¶
Validates given country code.
This performs a case-sensitive ISO 3166 country code validation.
Examples:
>>> country_code('GB', iso_format='alpha3')
# Output: False
>>> country_code('USA')
# Output: True
>>> country_code('840', iso_format='numeric')
# Output: True
>>> country_code('iN', iso_format='alpha2')
# Output: False
>>> country_code('ZWE', iso_format='alpha3')
# Output: True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Country code string to validate. |
required |
iso_format |
str
|
ISO format to be used. Available options are:
|
'auto'
|
ignore_case |
bool
|
Enable/Disable case-sensitive matching. |
False
|
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/country.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
validators.country.currency(value, /, *, skip_symbols=True, ignore_case=False)
¶
Validates given currency code.
This performs ISO 4217 currency code/symbol validation.
Examples:
>>> currency('USD')
# Output: True
>>> currency('ZWX')
# Output: ValidationError(func=currency, args={'value': 'ZWX'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Currency code/symbol string to validate. |
required |
skip_symbols |
bool
|
Skip currency symbol validation. |
True
|
ignore_case |
bool
|
Enable/Disable case-sensitive matching. |
False
|
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/country.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|