SilverWare\Validator\Rules\RemoteRule
An extension of the rule class for a remote rule.
By default, Parsley will consider any 2xx response code as valid.
Alternatively, you can use the 'reverse' option for $remoteValidator,
and Parsley will consider any 2xx response code as invalid.
- Author: Colin Tucker <colin@praxis.net.au>
- Copyright: 2017 Praxis Interactive
- License: https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
Synopsis
class RemoteRule
extends Rule
{
- // members
- private static string $default_type = 'remote';
- private static string $default_format = '{URLWithParams}';
- protected $url;
- protected array $params = ;
- protected array $options = ;
- protected $remoteValidator;
- // Inherited members from Rule
- protected $type;
- protected FormField $field;
- protected $format;
- protected $message;
- protected Validator $validator;
- protected string|array $attribute;
- // methods
- public void __construct()
- public $this setURL()
- public string getURL()
- public string getAbsoluteURL()
- public $this setParam()
- public mixed getParam()
- public boolean hasParam()
- public $this setParams()
- public array getParams()
- public $this setOptions()
- public array getOptions()
- public $this setRemoteValidator()
- public string getRemoteValidator()
- public string getURLWithParams()
- public string getMethod()
- public array getAttributes()
- public boolean isValid()
- public boolean isReverse()
- public boolean test()
- public boolean isValidStatusCode()
- public array getClientOptions()
- public string getDefaultMessage()
- // Inherited methods from Rule
- public void __construct()
- public abstract boolean test()
- public $this setType()
- public string getType()
- public string getDefaultType()
- public boolean hasType()
- public $this setFormat()
- public string getFormat()
- public boolean hasFormat()
- public string getDefaultFormat()
- public $this setAttribute()
- public string getAttribute()
- public string getValue()
- public string getFormattedValue()
- public $this setField()
- public FormField getField()
- public string getFieldName()
- public Form getForm()
- public FieldList getFormFields()
- public FormField getDataField()
- public $this setMessage()
- public string getMessage()
- public boolean hasMessage()
- public string getDefaultMessage()
- public $this setValidator()
- public Validator getValidator()
- public array getAttributes()
- public boolean isValid()
- public string replaceTokens()
- protected Backend backend()
- protected string attr()
- protected array getTokenNames()
- protected mixed getTokenValue()
Hierarchy
Extends
Members
private
- $default_format
—
string
Defines the default format for the rule. - $default_type
—
string
Defines the default type for the rule.
protected
- $attribute
—
SilverWare\Validator\string|array
The name of the data attribute used for this rule. - $field
—
SilverStripe\Forms\FormField
The form field instance associated with this rule. - $format
—
string
A tokenised string which defines the format for the validator attribute. - $message
—
string
The message displayed to the user when the rule test fails. - $options
—
array
An array of options for the validator. - $params
—
array
An array of parameters to pass to the remote validator. - $remoteValidator
—
string
The remote validator to use; Parsley ships with with 'default' and 'reverse'. - $type
—
string
A string which defines the rule type. - $url
—
string
The remote URL used to validate the value. - $validator
—
SilverWare\Validator\Validator
The form validator instance associated with this rule.
Methods
public
- __construct() — Constructs the object upon instantiation.
- getAbsoluteURL() — Answers the absolute URL of the receiver.
- getAttributes() — Answers the validator attributes for the associated form field.
- getClientOptions() — Answers an array of options for the HTTP client object.
- getDefaultMessage() — Answers the default message for the rule.
- getMethod() — Answers the HTTP request method used to call the remote validator.
- getOptions() — Answers the value of the options attribute.
- getParam() — Answers the value of a parameter with the specified name.
- getParams() — Answers the value of the params attribute.
- getRemoteValidator() — Answers the value of the remoteValidator attribute.
- getURL() — Answers the value of the url attribute.
- getURLWithParams() — Answers the defined URL with parameters included.
- hasParam() — Answers true if the receiver has a parameter with the specified name.
- isReverse() — Answers true if the validator is configured as 'reverse'.
- isValid() — Answers true if the rule is valid for use with the validator.
- isValidStatusCode() — Answers true if the given status code is considered valid.
- setOptions() — Defines the value of the options attribute.
- setParam() — Defines a parameter with the specified name and value.
- setParams() — Defines the value of the params attribute.
- setRemoteValidator() — Defines the value of the remoteValidator attribute.
- setURL() — Defines the value of the url attribute.
- test() — Answers the test result of the validator rule on the given value.
Inherited from SilverWare\Validator\Rule
protected
- attr() — Answers the appropriate validator attribute name for the given mapping name and arguments.
- backend() — Answers the validator backend.
- getTokenNames() — Answers an array of the token names found within the given string.
- getTokenValue() — Answers the value of the given token name.
public
- getAttribute() — Answers the name used by the rule for the form field attribute.
- getAttributes() — Answers the validator attributes for the associated form field.
- getDataField() — Answers a data field with the specified name.
- getDefaultFormat() — Answers the default format for the receiver.
- getDefaultMessage() — Answers the default message for the rule.
- getDefaultType() — Answers the default type for the receiver.
- getField() — Answers the value of the field attribute.
- getFieldName() — Answers the name of the associated form field.
- getForm() — Answers the form instance from the associated field.
- getFormFields() — Answers the list of fields from the associated form.
- getFormat() — Answers the value of the format attribute.
- getFormattedValue() — Answers the formatted value for the rule attribute.
- getMessage() — Answers the value of the message attribute.
- getType() — Answers the value of the type attribute.
- getValidator() — Answers the value of the validator attribute.
- getValue() — Answers the value of the rule attribute.
- hasFormat() — Answers true if the receiver has a format defined.
- hasMessage() — Answers true if the receiver has a message defined.
- hasType() — Answers true if the receiver has a type defined.
- isValid() — Answers true if the rule is valid for use with the validator.
- replaceTokens() — Replaces identified tokens within the given string.
- setAttribute() — Defines the name(s) used by the rule for the form field attribute.
- setField() — Defines the value of the field attribute.
- setFormat() — Defines the value of the format attribute.
- setMessage() — Defines the value of the message attribute.
- setType() — Defines the value of the type attribute.
- setValidator() — Defines the value of the validator attribute.
- test() — Answers the test result of the rule on the given value.