////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

image::apache-tinkerpop-logo.png[width=500,link="https://tinkerpop.apache.org"]

*x.y.z - Proposal 7*

== asBool() Step

=== Motivation

Given the additions of the `asString()` and `asDate()` steps in the 3.7 line, this proposal seeks to bridge another gap in language functionality, which is boolean parsing.

=== Definition

The `asBool()` step will convert the incoming traverser into a Boolean value.

If the incoming traverser is `null`, then `null` will be returned.

The incoming traverser can be of type:

*Boolean* - No change will happen, the Boolean will be returned as is.

*Number* - All non-zero values are considered `true`, zero values are considered `false`, `NaN` and `null` values are considered `null`, for example:
[cols=",",options="header",]
|===
|Numerical Value |Boolean Value
|3.14 |true
|1 |true
|0 |false
|0.0 |false
|-0.0 |false
|-1 |true
|-3.14 |true
|NaN |null
|null |null
|===

*String* - Strings will not be parsable into bool, except boolean strings. Non-parsable strings will return `null`:
[cols=",",options="header",]
|===
|Sting Value |Boolean Value
|"true" |true
|"false" |false
|"True" |true
|"False" |false
|"TRUE" |true
|"FALSE" |false
|"trUE" |true
|"faLSe" |false
|"null"|null
|"1" |null
|"hello" |null
|===

*All other types* - Invalid input into the step, an `IllegalArgumentException` will be thrown.
