<commit_before># frozen_string_literal: true

require 'dry/equalizer'

require 'dry/validation/constants'
require 'dry/validation/error_set'

module Dry
  module Validation
    # Result objects are returned by contracts
    #
    # @api public
    class Result
      include Dry::Equalizer(:values, :errors)

      # Build a new result
      #
      # @param [Dry::Schema::Result]
      #
      # @api private
      def self.new(values)
        result = super
        yield(result) if block_given?
        result.freeze
      end

      # @!attribute [r] values
      #   @return [Dry::Schema::Result]
      #   @api private
      attr_reader :values

      # @!attribute [r] error_set
      #   @return [ErrorSet]
      #   @api public
      attr_reader :error_set

      # Initialize a new result
      #
      # @api private
      def initialize(values)
        @values = values
        @error_set = ErrorSet.new(values.message_set.to_a, failures: true)
      end

      # Return error hash
      #
      # @return [Hash<Symbol=>Array<String>>]
      #
      # @api public
      def errors
        error_set.to_h
      end

      # Return all messages including hints from schema
      #
      # @api public
      def messages
        values.messages
      end

      # Check if result is successful
      #
      # @return [Bool]
      #
      # @api public
      def success?
        error_set.empty?
      end<commit_msg>Alias messages => errors<commit_after># frozen_string_literal: true

require 'dry/equalizer'

require 'dry/validation/constants'
require 'dry/validation/error_set'

module Dry
  module Validation
    # Result objects are returned by contracts
    #
    # @api public
    class Result
      include Dry::Equalizer(:values, :errors)

      # Build a new result
      #
      # @param [Dry::Schema::Result]
      #
      # @api private
      def self.new(values)
        result = super
        yield(result) if block_given?
        result.freeze
      end

      # @!attribute [r] values
      #   @return [Dry::Schema::Result]
      #   @api private
      attr_reader :values

      # @!attribute [r] error_set
      #   @return [ErrorSet]
      #   @api public
      attr_reader :error_set

      # Initialize a new result
      #
      # @api private
      def initialize(values)
        @values = values
        @error_set = ErrorSet.new(values.message_set.to_a, failures: true)
      end

      # Return error hash
      #
      # @return [Hash<Symbol=>Array<String>>]
      #
      # @api public
      def errors
        error_set.to_h
      end
      alias_method :messages, :errors

      # Check if result is successful
      #
      # @return [Bool]
      #
      # @api public
      def success?
        error_set.empty?
      end
{'fraction_non_alphanumeric': 0.09113924050632911, 'fraction_numerical': 0.0, 'mean_word_length': 1.9024134312696748, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5497600', 'n_tokens_mistral': 833, 'n_tokens_neox': 810, 'n_words': 217}