silverstripe/required-field-validator

Adds required field validation to dataobjects when used outside of the cms|controller|form context

Installs: 119

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

dev-master 2018-01-31 06:54 UTC

This package is auto-updated.

Last update: 2020-05-13 01:11:57 UTC


README

This module adds a required field validation mechanism to DataObjects which can be used outside of the cms|controller|form context. It does so by adding a hook to the DataObject::validate() method to check for statically configured fields.

Installation

composer require silverstripe/required-field-validator

Configuration/Usage instructions

Required fields can be set on a DataObject subclass by adding private static $required_fields to it as below

Configuration example:

class MyObject extends DataObject
{
    private static $db = [
        'Title' => 'Varchar(20)'
    ];
    
    private static $required_fields = [
        'Title'
    ]
}
    

Bugtracker

Bugs are tracked on github.com.