class Athena::Validator::Constraints::ISSN

Overview

Validates that a value is a valid International Standard Serial Number (ISSN). The underlying value is converted to a string via #to_s before being validated.

NOTE As with most other constraints, nil and empty strings are considered valid values, in order to allow the value to be optional. If the value is required, consider combining this constraint with AVD::Constraints::NotBlank.

Configuration

Optional Arguments

case_sensitive

Type: Bool Default: false

The validator will allow ISSN values to end with a lowercase x by default. When set to true, this requires an uppcase case X.

require_hypen

Type: Bool Default: false

The validator will allow non hyphenated values by default. When set to true, this requires a hyphenated ISSN value.

message

Type: String Default: This value is not a valid International Standard Serial Number (ISSN).

The message that will be shown if the value is not a valid ISSN.

Placeholders

The following placeholders can be used in this message:

groups

Type: Array(String) | String | Nil Default: nil

The validation groups this constraint belongs to. AVD::Constraint::DEFAULT_GROUP is assumed if nil.

payload

Type: Hash(String, String)? Default: nil

Any arbitrary domain-specific data that should be stored with this constraint. The payload is not used by Athena::Validator, but its processing is completely up to you.

Defined in:

constraints/issn.cr

Constant Summary

CHECKSUM_FAILED_ERROR = "62c01bab-fe8f-4072-aac8-aa4bdcde8361"
INVALID_CASE_ERROR = "66f892f3-9eed-4176-b823-0dafde72202a"
INVALID_CHARACTERS_ERROR = "85c5d3aa-fd0a-4cd0-8cf7-e014e6379d59"
MISSING_HYPHEN_ERROR = "d6c120a9-0b56-4e45-b4bc-7fd186f2cfbd"
TOO_LONG_ERROR = "fab8e3ea-2f77-4da7-b40f-d9b24ff8c0cc"
TOO_SHORT_ERROR = "85c5d3aa-fd0a-4cd0-8cf7-e014e6379d59"

Constructors

Instance Method Summary

Instance methods inherited from class Athena::Validator::Constraint

add_implicit_group(group : String) : Nil add_implicit_group, groups : Array(String) groups, groups=(groups : Array(String)) groups=, message : String message, payload : Hash(String, String)? payload, validated_by : AVD::ConstraintValidator.class validated_by

Constructor methods inherited from class Athena::Validator::Constraint

new(message : String, groups : Array(String) | String | Nil = nil, payload : Hash(String, String)? = nil) new

Class methods inherited from class Athena::Validator::Constraint

error_name(error_code : String) : String error_name

Constructor Detail

def self.new(case_sensitive : Bool = false, require_hypen : Bool = false, message : String = "This value is not a valid International Standard Serial Number (ISSN).", groups : Array(String) | String | Nil = nil, payload : Hash(String, String)? = nil) #

[View source]

Instance Method Detail

def case_sensitive? : Bool #

[View source]
def require_hypen? : Bool #

[View source]
def validated_by : AVD::ConstraintValidator.class #

Returns the AVD::ConstraintValidator.class that should handle validating self.


[View source]