Packages

  • package root

    Documentation for the Axiell Schema Project

    Documentation for the Axiell Schema Project

    Overview

    The Axiell Schema Project provides a small library for validating JSON documents against a JSON Schema. The library conforms to the JSON Schema Draft #7 specification.

    The library is based on a few simple principles, namely:

    • referential transparency. Each of the methods in the library is referentially transparent, that is if the method is called with the same arguments it will always return the same value and the method does not have any side effect (e.g. update globals, change the operating environment, etc).
    • minimal functionality. The library is designed to be small incorporating a small number of dependencies. The number of methods associated with a class/object is restricted to those that provide a base level of functionality.
    • support multiple JSON libraries. It should be possible to use the library with any number of different JSON library packages (e.g json4s, jackson, etc). The current library only supports json4s, but a facade approach should be added to hide individual library implementations.
    • generic "format" implementations. The JSON Schema specification mandates a standard set of "format" types that can be used to validate string values. Each "format" type is implemented as a class with the components of the type available.
    • full error handling. Error resulting from the validation process are returned as a list of validation failures. All possible errors should be returned for a single call, eliminating the need to fix a single error and then recall a method.

    Package structure

    The com.axiell.schema packages consists of a number of utilities, where each utility provides a single piece of functionality. Since the library validates JSON structures two main components are provided. The first component (com.axiell.schema.Schema) allows JSON documents conforming to the JSON Schema specification to be read. Once read a resolution process may be required to resolve any external references defined in the document.

    The second component (com.axiell.schema.SchemaValidator) takes a resolved schema and allows JSON documents to be validated against that schema. When creating a validator it is also possible to incorporate your own "format" types for validation.

    A set of auxiliary components implement parsers for many of the "format" types and can be used independently of the validator itself.

    Notable utilities are:

    • Schema wrapper around a JSON document containing the document itself, its $id value and resolution mappings for all $id and $ref directives.
    • SchemaValidator takes a Schema and an optional handler for "format" types and provides a validation method for arbitrary JSON documents.
    • Implicits implements implicit methods and classes used to convert one class to another or pimp methods onto existing classes (e.g. same() method to JValue class).
    • various auxiliary classes for handling "format" types including:

    Dependencies

    The list of dependencies are:

    • Axiell Util Library provides error handling classes and methods that allow multilingual error messages to be generated.
    • JSON for Scala Library provides mthods for dealing with JSON structures. The routines work around an AST (Abstract Syntax Tree) used to represent a JSON document.
    • Cats Functional Programming Library provides various traits, classes and methods that simplify functional programming in Scala. Also provides the Validated class used to return lists of validation errors.
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package axiell
    Definition Classes
    com
  • package schema

    Contains types used by the library.

    Contains types used by the library.

    In order to simplify method signatures a series of types are defined. The types are used throughout the library.

    Definition Classes
    axiell
  • package instances
    Definition Classes
    schema
  • package syntax
    Definition Classes
    schema
  • Assertions
  • Context
  • EmailAddress
  • Formats
  • Hostname
  • Implicits
  • Ipv4Address
  • Ipv6Address
  • JsonPointer
  • RelativeJsonPointer
  • Resolver
  • Schema
  • SchemaValidator
  • SchemaWalker
  • Validator

object EmailAddress extends Serializable

Creates an EmailAddress by parsing an email address string.

The parser conforms to both RFC 5322, section 3.4.1, which outlines what is a valid email address using the ASCII character set and RFC 6531 which contains extensions allowing for Unicode based email addresses.

The parser will strip out any comments (enclosed in backets) from the email address and divide the address into two parts. The first part is the local section which occurs before the @ symbol and the second part is the domain which is after the @ symbol. Any escapes are interpreted and removed from the values.

Source
EmailAddress.scala
See also

"RFC 5322, section 3.4.1"

"RFC 6531"

Linear Supertypes
Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EmailAddress
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. def fromString(value: String, idn: Boolean, obsolete: Boolean): Either[Error, EmailAddress]

    Parses an email address allowing for both Unicode characters and strict implementation of RFC 5322.

    Parses an email address allowing for both Unicode characters and strict implementation of RFC 5322.

    RFC 5322 contains a strict set of specifications and also allows for obsolete rules. In general email addresses should be written to conform to the strict interpretation of RFC 5322, while the parsing of email addresses should include the obsolete rules.

    The obsolete argument can be used to indicate whether the obsolete rules should be applied when parsing an email address. The other fromString methods have obsolete rules enabled when parsing email addresses.

    value

    email address string to be parsed

    idn

    true value to parse with RFC 6531 otherwise RFC 5322 is used

    obsolete

    true to enable more flexible obsolete parsing rules

    returns

    EmailAddress if valid otherwise an Error

  10. def fromString(value: String, idn: Boolean): Either[Error, EmailAddress]

    Parses an email address conforming to either RFC 5322, section 3.4.1 or RFC 6531.

    Parses an email address conforming to either RFC 5322, section 3.4.1 or RFC 6531.

    The idn argument controls whether the parser obeys the RFC 5322 or RFC 6531 specification. A true value will enable RFC 6531 support otherwise RFC 5322 is used. The email address is split into a local part containing the user or group name and the domain part containing the fully qualified machine name to handle the email address.

    value

    email address string to be parsed

    idn

    true value to parse Unicode addresses otherwise ASCII

    returns

    EmailAddress if valid otherwise an Error

  11. def fromString(value: String): Either[Error, EmailAddress]

    Parses an email address conforming to RFC 5322, section 3.4.1.

    Parses an email address conforming to RFC 5322, section 3.4.1.

    An ASCII only email address is parsed and broken into its local and domain parts. An EmailAddress is returned containing the two parts.

    value

    containing email address to be parsed

    returns

    EmailAddress if valid otherwise an Error

  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped