Skip to content

class Athena::Validator::Constraints::ISSN
inherits Athena::Validator::Constraint #

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_hyphen#

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:

  • {{ value }} - The current (invalid) value.

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.

Constants#

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#

.new(case_sensitive : Bool = false, require_hyphen : 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 = nil)#

View source

Methods#

#case_sensitive? : Bool#

View source

#require_hyphen? : Bool#

View source

#validated_by : AVD::ConstraintValidator.class#

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

View source