Class: GdsDataValidation

Inherits:
Object
  • Object
show all
Defined in:
lib/gds-data-validation/version.rb,
lib/gds-data-validation.rb,
lib/gds-data-validation/validation_generator.rb

Overview

version.rb

Defined Under Namespace

Classes: ValidationCheckerGenerator

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.create(schema_definition) ⇒ Class

create an data validation class which is checking incoming data against a specified schema definition

Examples:

require 'gds-data-validaion'

dataValidation = GdsDataValidation.create( <<-EOS )
schema = @t_int
EOS

dataValidation.check( 10 )    # => true
dataValidation.check( "a" )   # => false

Parameters:

  • schema_definition (String)

    the schema definition to be used for data validation

Returns:

  • (Class)

    anonymous class for data validation



28
29
30
31
# File 'lib/gds-data-validation.rb', line 28

def create( schema_definition )
  vcg = ValidationCheckerGenerator.new
  vcg.generate( LDLgeneratedLanguage::Language_gds_check.parse( schema_definition ) )
end

.create_from_file(file_name) ⇒ Class

create an data validation class which is checking incoming data against a specified schema definition stored in a file

Parameters:

  • file_name (String)

    file name, this file contains the schema definition

Returns:

  • (Class)

    anonymous class for data validation



38
39
40
41
# File 'lib/gds-data-validation.rb', line 38

def create_from_file( file_name )
  vcg = ValidationCheckerGenerator.new
  vcg.generate( LDLgeneratedLanguage::Language_gds_check.parse( File.read( file_name ) ) )
end