PHPackages                             signify-nz/silverstripe-dependentrequiredfields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. signify-nz/silverstripe-dependentrequiredfields

AbandonedArchivedSilverstripe-vendormodule[Validation &amp; Sanitization](/categories/validation)

signify-nz/silverstripe-dependentrequiredfields
===============================================

SilverStripe vendor module providing a validator which allows for fields to be required based on the values of other fields.

1.1.1(5y ago)12581[1 issues](https://github.com/signify-nz/silverstripe-dependentrequiredfields/issues)BSD-3-ClausePHPCI failing

Since Jun 16Pushed 5y ago8 watchersCompare

[ Source](https://github.com/signify-nz/silverstripe-dependentrequiredfields)[ Packagist](https://packagist.org/packages/signify-nz/silverstripe-dependentrequiredfields)[ Docs](https://github.com/signify-nz/silverstripe-dependentrequiredfields)[ RSS](/packages/signify-nz-silverstripe-dependentrequiredfields/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (5)Used By (0)

[![Build Status](https://camo.githubusercontent.com/b072b1f91664b1b2374e0caaf1f406ffc807fac1c440263bd34b0e73c0abed0f/68747470733a2f2f7472617669732d63692e636f6d2f7369676e6966792d6e7a2f73696c7665727374726970652d646570656e64656e7472657175697265646669656c64732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/signify-nz/silverstripe-dependentrequiredfields)[![codecov](https://camo.githubusercontent.com/05b8a09ed7b3aa1ebb4c5c562ec65c7a405379bebec87466f67be20db2aa0740/68747470733a2f2f636f6465636f762e696f2f67682f7369676e6966792d6e7a2f73696c7665727374726970652d646570656e64656e7472657175697265646669656c64732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/signify-nz/silverstripe-dependentrequiredfields)

Dependent Required Fields
=========================

[](#dependent-required-fields)

The Dependent Required Fields module provides a validator which extends RequiredFields and allows for fields to be required based on the values of other fields.

SearchFilters are used to provide a variety of ways to compare values, depending on what causes the fields to be required. See [SilverStripe's documentation on SearchFilters](https://docs.silverstripe.org/en/4/developer_guides/model/searchfilters/) for more about how to use those.

Requirements
------------

[](#requirements)

- [SilverStripe Framework ^4](https://github.com/silverstripe/silverstripe-framework)

Installation
------------

[](#installation)

**Composer:**

```
    composer require signify-nz/silverstripe-dependentrequiredfields

```

Documentaion
------------

[](#documentaion)

No configuration is required. See Example Usage below for an example of how this validator is used.

- [Changelog](CHANGELOG.md)
- [Contributing](CONTRIBUTING.md)
- [Issues](https://github.com/signify-nz/silverstripe-dependentrequiredfields/issues)
- [License](LICENSE.md)

Example Usage
-------------

[](#example-usage)

In the below example, we have fields with various levels of dependency on whether they are required or not.
`AlwaysRequiredField` will be required regardless of the values of other fields.
`ExactValueField` will only be required if the value of `DependencyField` exactly equals `someExactValue`.
`StartsWithField` will only be required if the value of `DependencyField` starts with the string `some`.

```
