////
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

https://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.
////


== nullable



=== Purpose


Allows a property to be set to `null`. By default Grails does not allow `null` values for properties.


=== Examples


[source,groovy]
----
age nullable: true
----


=== Description


Set to `true` if the property allows `null` values.

This constraint influences  link:{hibernate5Guide}/manual/index.html#constraints[schema generation].

Error Code: `className.propertyName.nullable`

NOTE: Web requests resulting from form submissions will have blank strings, not `null`, for input fields that have no value. Keep this in mind when doing mass property binding to properties that are not nullable.  The default behavior is such that a blank string will not validate for `nullable: false` since the data binder will convert blank strings to null.  This includes empty strings and blank strings.  A blank string is any string such that the `trim()` method returns an empty string.  To turn off the conversion of empty strings to null set the `grails.databinding.convertEmptyStringsToNull` property to `false` in `application.groovy`. See the link:{guidePath}/theWebLayer.html#dataBinding[data binding] section for more details on data binding.

[source,groovy]
.grails-app/conf/application.groovy
----

// the default value for this property is true
grails.databinding.convertEmptyStringsToNull = false

// ...
----
