# Functional vs Object-oriented approaches to validation

DevFeed: [Functional vs Object-oriented approaches to validation](<https://devfeed.tech/articles/functional-vs-object-oriented-approaches-to-validation-32148.md>)

Original publisher: [Read original article](<https://adambard.com/blog/oo-vs-functional-form-validation/>)

Published: 2014-12-07T00:00:00Z

Content type: tutorial

Language: en

Sources: [Adam Bard](<https://devfeed.tech/sources/adam-bard.md>)

Topics: [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Python](<https://devfeed.tech/topics/python.md>), [Exception](<https://devfeed.tech/topics/exception.md>)

Tags: [exception](<https://devfeed.tech/tags/exception.md>), [functional](<https://devfeed.tech/tags/functional.md>), [object-oriented](<https://devfeed.tech/tags/object-oriented.md>), [python](<https://devfeed.tech/tags/python.md>), [validation](<https://devfeed.tech/tags/validation.md>)

## AI overview

This article compares functional and object-oriented approaches to validating and cleaning data in Python. It presents equivalent validation designs that return cleaned data on success and collect errors when validation fails, while discussing closures, exceptions, and execution flow.

## Source excerpt

Functional programming is often described in terms of its contrast with object-oriented programs; that is, you write functions that act on data instead of objects that wrap data and use methods to act on themselves. Functional programming wonks (like me) will tell you that writing code this way is generally better than OO, but I don't want to do that (right now). However, in this post, I'm not here to argue either side. Today, I'm just going to demonstrate a few equivalent approaches to the same problem: validating data.