Link Search Menu Expand Document

types

Provides type validation and conversion capabilities

This module is wrapper around the builtin functions where applicable and does and return the same thing as the builtin alternative.

Functions


types.of(value: any)
returns the name of the type of value
  • method implemented as part of core language features
types.digit(value: char)
returns true if the value is a character and digit, otherwise returns false
return bool
types.alpha(value: char)
returns true if the value is a character and alphabetic, otherwise returns false
return bool
types.int(value: any)
returns true if the value is an integer or false otherwise
return bool
types.bool(value: any)
returns true if the value is a boolean or false otherwise
return bool
types.is_number(value: any)
returns true if the value is a number or false otherwise
  • this method also returns true for integers
return bool
types.char(value: any)
returns true if the value is a single character or false otherwise
return bool
types.string(value: any)
returns true if the value is a string or false otherwise
return bool
types.bytes(value: any)
returns true if the value is a bytes or false otherwise
return bool
types.list(value: any)
returns true if the value is a list or false otherwise
return bool
types.is_dict(value: any)
returns true if the value is a dictionary or false otherwise
return bool
types.object(value: any)
returns true if the value is an object or false otherwise
return bool
types.function(value: any)
returns true if the value is a function or false otherwise
return bool
types.class(value: any)
returns true if the value is a class or false otherwise
return bool
types.file(value: any)
returns true if the value is a file or false otherwise
return bool
types.iterable(value: any)
returns true if the value is an iterable or false otherwise
return bool
types.callable(value: any)
returns true if the value is a callable function or class and false otherwise
return bool
types.instance(value: any, type: class)
returns true if the value is an instance the given class, false otherwise
return bool

Classes


class Convert


The Convert class handles conversion from one type to another

class Convert methods


Convert(value: any)
constructor
to_int()
convert the value into an integer.
  • classes may override the return value by declaring a to_int() function.
return bool
to_number()
convert the value into a number.
  • classes may override the return value by declaring a to_number() function.
return bool
to_string()
convert the value into a string.
  • classes may override the return value by declaring a to_string() function.
return bool
to_bool()
converts the value into a boolean.
  • classes may override the return value by declaring a to_bool() function.
return bool
to_list()
convert the value into a list.
  • classes may override the return value by declaring a to_list() function.
return bool
to_dict()
convert the value value into a dictionary.
  • classes may override the return value by declaring a to_dict() function.
return bool

Back to top

Copyright © 2021 Ore Richard Muyiwa. Distributed under the MIT license.