Version: current

# Class ValidationResult

A class that combined as a boolean result with an optional list of error messages. This is used for returning validation results from validators

  Object
  ValidationResult

Package: sapphire\core
Located at sapphire/core/ValidationResult.php

## Methods summary

`public` | # `__construct( mixed $valid = true, mixed $message = null )` Create a new ValidationResult. By default, it is a successful result. Call $this->error() to record errors. Create a new ValidationResult. By default, it is a successful result. Call $this->error() to record errors. #### Overrides `Object::__construct`
`public` | # `error( mixed $message, mixed $code = null )` Record an error against this validation result, Record an error against this validation result, #### Parameters $message $message The validation error message $code $code An optional error code string, that can be accessed with $this->codeList().
`public` | # `valid( )` Returns true if the result is valid. Returns true if the result is valid.
`public` | # `messageList( )` Get an array of errors Get an array of errors
`public` | # `codeList( )` Get an array of error codes Get an array of error codes
`public` | # `message( )` Get the error message as a string. Get the error message as a string.
`public` | # `starredList( )` Get a starred list of all messages Get a starred list of all messages
`public` | # `combineAnd( `ValidationResult` $other )` Combine this Validation Result with the ValidationResult given in other. It will be valid if both this and the other result are valid. This object will be modified to contain the new validation information. Combine this Validation Result with the ValidationResult given in other. It will be valid if both this and the other result are valid. This object will be modified to contain the new validation information.

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `defineMethods()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`protected mixed` | $isValid | # Boolean - is the result valid or not Boolean - is the result valid or not
`protected array` | $errorList | # Array of errors Array of errors

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -