validations_generator 0.8.4

  • Readme
  • Changelog
  • Installing
  • 53

Validations Generator #

Pub Package Build Status

A validations generator for the package validations

See that package for main setup and it's usage.

Usage #


pub run build_runner build

Internationalization #

The generator is capable of generating message methods which use the intl package.

The string to be translated will be the message you've specified in the annotation or else the default message for the annotation.

In order to enable the generation of intl add the following to your build.yaml configuration.

          use_intl: true 

Intl Example #

Given an annotation like this:

  value: 350,
  message: r'The top speed $validatedValue is higher than $value',
int topSpeed;

Without intl the generated code will be:

static String topSpeedMaxMessage(num value, Object validatedValue) {
  return 'The top speed $validatedValue is higher than $value';

With intl:

static String topSpeedMaxMessage(num value, Object validatedValue) =>
   'The top speed $validatedValue is higher than $value',
   name: 'topSpeedMaxMessage',
   args: [value, validatedValue]

Note: Make sure you import the package:intl package from the source file in order for the generated code to find the package.

Debugging #

Run pub run build_runner generate-build-script

And use the generated build script for debugging.

0.8.4 #

  • Return early in case foreign annotation cannot be computed.

0.8.3 #

  • update validations dependency to 0.8.3

0.8.2 #

  • fix affectFields to only contain fields referenced by the validator
  • statically determine whether an annotation is a validation annotation, instead of testing against known runtime types.

0.8.1 #

  • fix getAnnotation failing to detect @Constraint annotation

0.8.0 #

  • add @Target to field annotations
  • add @Constraint to field annotations
  • fix time unit validator
  • improve class level validations and error messages

0.7.0 #

  • add support for class level validators
  • add a FieldMatch class level validator
  • introduce @property to support constructing class level validators.

0.6.0 #

  • make internationalization of messages optional.
  • generate to shared part files
  • extension changed from .gval.dart to .g.dart

0.5.1 #

  • update validators dependency.

0.5.0 #

  • change generated class prefix from $_ to _$ (private).

0.4.0 #

  • Add optional fields parameter to Genvalidator to generate validators.

0.3.0 #

  • Update validations dependency

0.2.0 #

  • Wrap property validators with a FieldValidator to enable type checking.

0.1.0 #

  • Alpha version

0.0.1 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  validations_generator: ^0.8.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:validations_generator/validations_generator.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: other

Primary library: package:validations_generator/validations_generator.dart with components: io, build, mirrors.

Health issues and suggestions

Document public APIs. (-1 points)

3 out of 3 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (analyzer).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and validations_generator.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
analyzer ^0.36.0 0.36.4 0.39.1
build >=0.12.6 <2.0.0 1.2.2
build_config >=0.2.6 <0.5.0 0.4.1+1
code_builder ^3.2.0 3.2.1
dart_style ^1.2.8 1.2.9 1.3.3
logging ^0.11.3+2 0.11.3+2
meta ^1.0.0 1.1.8
source_gen ^0.9.4+2 0.9.4+4 0.9.4+6
validations ^0.8.4 0.8.5+1
Transitive dependencies
args 1.5.2
async 2.4.0
built_collection 4.3.0
built_value 7.0.0
charcode 1.1.2
checked_yaml 1.0.2
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
fixnum 0.10.11
front_end 0.1.19 0.1.29
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
json_annotation 3.0.0
kernel 0.3.19 0.3.29
matcher 0.12.6
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pub_semver 1.4.2
pubspec_parse 0.1.5
quiver 2.1.2+1
rational 0.3.6
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
validators 2.0.0+1
watcher 0.9.7+12
yaml 2.2.0
Dev dependencies
build_runner ^1.6.1
build_test ^0.10.8
collection ^1.14.11 1.14.12
decimal ^0.3.3 0.3.5
intl 0.15.8 0.16.0
pedantic ^1.8.0 1.8.0+1
test ^1.6.4