Git Product home page Git Product logo

chickpea's Introduction

joss moffatt header


๐Ÿ‘จ About Me

  • ๐Ÿ  Iโ€™m currently living in Nottingham, United Kingdom.
  • ๐Ÿ‘จโ€๐Ÿ’ป Iโ€™m currently working as a Software Engineer at Capital One.
  • ๐Ÿบ Iโ€™m a big beer fan.
  • ๐ŸŽง I can chat your ear off about electronic music.
  • ๐Ÿ”Ž I have specialities in automated reasoning and software security.
  • ๐Ÿงช I like testing cloud architectures.

๐Ÿ‘ท What I'm Working On


โ˜๏ธ My Certifications

chickpea's People

Contributors

dependabot[bot] avatar jossmoff avatar

Stargazers

 avatar

Watchers

 avatar  avatar

chickpea's Issues

Add `@EthereumAddress` Validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Akin to #11 we would want a similar thing for Ethereum!

Solution

There is a regex for the Ethereum address. We might want to also do the SHA validation too. But this could be easily added.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@ARN` validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

It would be great to add a bean validator for a AWS ARN string.

Solution

The format for the ARN can be seen here. If we break down the validators into each component that can be reusable across future AWS validators.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@ISBN10`, `@ISBN13` and `@ISBN` validators

Search before asking

  • I had searched in the issues and found no similar issues.

Description

It would be useful for an @ISBN validator as we have no existing solution for this.

Solution

There is an ISBNValidator from apache commons. The documentation is here. We can use this to implement the isValid method. It has both an ISBN-10, ISBN-13 and a general ISBN validator that can be used for each annotation.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `containsInvalidValues` to `ConstraintViolationSetAssert`

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Instead of writing out lots of assertions for different values it would be useful to have a custom containsInvalidValues constraints so this:

assertThat(violations).containsInvalidValue(tooShortPassword);
    assertThat(violations).containsInvalidValue(tooLongPassword);
    assertThat(violations).containsInvalidValue(missingLowerCasePassword);
    assertThat(violations).containsInvalidValue(missingUpperCasePassword);
    assertThat(violations).containsInvalidValue(missingSpecialCharacterPassword);
    assertThat(violations).containsInvalidValue(missingNumericCharacterPassword);

Becomes this:

assertThat(violations).containsInvalidValues(tooShortPassword, tooLongPassword, missingLowerCasePassword, missingUpperCasePassword, missingSpecialCharacterPassword, missingNumericCharacterPassword);

Solution

public ConstraintViolationSetAssert<T> containsInvalidValues(Object... invalidValues) {
  for(Object invalidValue : invalidValues) {
    containsInvalidValue(invalidValue);
  }
  return this;
}

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@Superset` and `@Subset` annotations

Search before asking

  • I had searched in the issues and found no similar issues.

Description

It's a common check to validate that we have some a collection that is either a subset or superset of some other collection.

Solution

We can use Set.containsAll(Collection <?> C) (docs) to do this check. We will convert the collection to a list for superset by using the following:

list.stream().collect(Collectors.toSet());

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add credit to jvbe project

Search before asking

  • I had searched in the issues and found no similar issues.

Description

This project is inspired to be a modern and active version of jvbe. We should credit this in the readme

Solution

Add credits and link to jvbe in the README under the heading:

๐ŸŽฅ Credits

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Spelling mistakes in issue templates

Search before asking

  • I had searched in the issues and found no similar issues.

Version

No version as of yet but will be for 1.0.0

What's Wrong?

Spelling mistakes!

What You Expected?

No spelling mistakes!

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add License

Search before asking

  • I had searched in the issues and found no similar issues.

Version

1.0.0

What's Wrong?

Currently we have no license

What You Expected?

A MIT license

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@Ordered` validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

There are very few annotations for list. A common property that you might want to validate is that the List is sorted according to the natural ordering.

Solution

  1. Use the custom generation script to generate base classes for @Ordered
  2. Implement the validation using something similar too:
return list.stream()
                .sorted()
                .collect(Collectors.toList())
                .equals(list);

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Create script to auto generate Annotation template

Search before asking

  • I had searched in the issues and found no similar issues.

Description

The base files for an @Annotation have a consistent format:

  • src/main/java/dev/joss/chickpea/constraints/AnnotationName.java
  • src/main/java/dev/joss/chickpea/constraints/AnnotationNameValidator.java
  • src/test/java/dev/joss/chickpea/constraints/AnnotationNameTest.java

We can add some standard generator that does this for us.

Solution

Using a Python script we can automatically generate this and write the files to the correct location. We will need 3 inputs to get started:

  • AnnotationName - Name of the annotation
  • Package offset - The packages off of dev.joss.chickpea.constraints e.g. str, aws, numeric etc.
  • Author name - To give credits in the Javadocs

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@Square` validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Useful to have an annotation that checks a given number is a perfect square.

Solution

Look at G4G article for some examples.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@Prime` validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Add the validator to check if a given number is prime which can be useful for security purposes.

Solution

Use Miller-Rabin and look at the following thread

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Adding PR template

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Could probably use a PR template

Solution

Add a PR template

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@CurrencyCode` validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Currency code is a very commonly used string and we currently don't support it. The ISO-4217 defines all the currencies we should support.

Solution

There is a commons validator!

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@Password` Validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

It would be great to have a password validator annotation which checks:

  • Bounds on length
  • If it contains digits
  • If it contains lower case chars
  • If it contains uppercase chars
  • If it contains special chars

And you can toggle each of these on or off

Solution

Want the @Password annotation.

Password length should be between 8 and 64 as per OWASP.
Password special characters as per OWASP
Password requirements that Google enforce would be a good place to focus the format.

These can be opted out something like

@Password(minLength=4, specialChars=false, lowerCase=false, numbers=false)

Would imply our password must be between 4 and 64 digits and not contain special, lowercase or numeric characters.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Add `@BitcoinAddress` validator

Search before asking

  • I had searched in the issues and found no similar issues.

Description

It would be useful for a @BitcoinAddress validator as we have no existing solution for this and Bitcoin is a relatively prominent item currently.

Solution

A regular expression for a bitcoin address can be seen here. We can implement the isValid method using this.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.