Convert different values into boolean
@param mixed $field
@return bool|null
559793
protected function validateBool($field)
    {
        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $this->setSubmitted($field, (int) filter_var($value, FILTER_VALIDATE_BOOLEAN));
        return true;
    }
145317
private function IsFieldLocked($field)
    {
        if (!is_array($this->locked_fields)) {
            return false;
        }
        $locked_tables = array_keys($this->locked_fields);
        $locked_fields = array_values($this->locked_fields);
        $_locked_fields = array();

        foreach ($locked_fields as $locked_field) {
            if (is_array($locked_field)) {
                foreach ($locked_field as $_locked_field) {
                    $_locked_fields[] = $_locked_field;
                }
            } else {
                $_locked_fields[] = $locked_field;
            }
        }

        if (in_array($this->table, $locked_tables) and in_array($field, $_locked_fields)) {
            return true;
        }

        return false;
    }
1248034
protected function validateBoolean($value, ValidationField $field) {
        $value = $value === null ? $value : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
        if ($value === null) {
            $field->addTypeError($value, 'boolean');
            return Invalid::value();
        }

        return $value;
    }
924604
public function map(Field $field)
    {
        if ($field->value['latitude'] === null || $field->value['longitude'] === null) {
            return null;
        }

        return sprintf('%F,%F', $field->value['latitude'], $field->value['longitude']);
    }
1372156
public function fieldPosition($field)
    {
        if ($field instanceof FormField) {
            $field = $field->getName();
        }

        $i = 0;
        foreach ($this->dataFields() as $child) {
            if ($child->getName() == $field) {
                return $i;
            }
            $i++;
        }

        return false;
    }
222470
public function normalizeValues($field, $values)
    {
        if (!$this->_types) {
            return $values;
        }

        $type = $this->_types[$field];

        $map = ['int' => 'intval', 'float' => 'floatval', 'string' => 'strval', 'bool' => 'boolval'];
        if (isset($map[$type])) {
            $values = array_map($map[$type], $values);
        } else {
            foreach ($values as $k => $value) {
                $values[$k] = $this->normalizeValue($field, $value);
            }
        }

        return $values;
    }
192667
public function castValue($field, $value)
    {
        if (null === $value) {
            return $value;
        }

        $cast = $this->getCast($field);

        switch ($cast) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'string':
                return (string) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'object':
                return json_decode($value);
            case 'array':
            case 'json':
                return json_decode($value, true);
            case 'date':
            case 'datetime':
                return $this->toDateTime($value);
            case 'timestamp':
                return $this->toDateTime($value)->getTimestamp();
            case class_exists($cast):
                return new $cast($value);
            case is_callable($cast):
                return $cast($value);
            default:
                return $value;
        }
    }
646246
public function hasParam($field) {
        foreach ($this->getParams() as $param) {
            if ($param instanceof Expr && $param->getField() === $field) {
                return true;
            }
        }

        return false;
    }
943367
public function hasField(string $field): bool
    {
        if ($this->fields === null) {
            return false;
        }

        return in_array($field, $this->fields);
    }
562226
protected function getField($field)
    {
        if ($this->isFieldSupported($field) && isset($this->fields[ $field ])) {
            return $this->fields[ $field ];
        }

        return null;
    }
418124
public function remove($field)
    {
        return (bool) $this->getClient()->hdel(
            $this->getKey()->getName(), $field
        );
    }
1028485
public function getValue($field) {
        if (is_array($this->values)) {
            return isset($this->values[$field]) ? $this->values[$field] : null;
        }
        if (is_object($this->values)) {
            return $this->values->$field;
        }
        return null;
    }
335761
public function hasFilter(string $field): bool
    {
        foreach ($this->filters as $filter) {
            if ($filter->hasFilter($field)) {
                return true;
            }
        }

        return false;
    }
876766
public function isValidField(string $field): bool {
        $result = empty($this->errors[$field]);
        return $result;
    }
532171
public function getOptionValue($field)
    {
        $postType = getPostType($this->getTable());
        if(!$postType) {
            throw new \Exception("Post type ".$this->getTable()."' does not exists!");
        }
        return $postType->getMultioptionFieldValue($field, $this->$field);
    }
852977
protected function access($values, string $field)
    {
        return isset($values[$field]) ? $values[$field] : null;
    }
154265
public function isRequired($field)
    {
        $parts = explode('.', $field);
        $entity = $this->entity($parts);

        $isNew = true;
        if ($entity instanceof EntityInterface) {
            $isNew = $entity->isNew();
        }

        $validator = $this->_getValidator($parts);
        $fieldName = array_pop($parts);
        if (!$validator->hasField($fieldName)) {
            return false;
        }
        if ($this->type($field) !== 'boolean') {
            return $validator->isEmptyAllowed($fieldName, $isNew) === false;
        }

        return false;
    }