Comments (7)
@bchavez this is freaking awesome! Probably the best response to an issue I've ever got. For this alone, I'll spend some time and raise the PR. Thanks again my friend and keep up the great work :) 👍
from bogus.
Ahhh, now I see. Well, I screwed up that one pretty badly didn't I?
The dyslexia is real. I have no idea why I read "Sort" as "Short" (as in small). Lmao. 😃
My bad.
I'll rename this API to SortCode
as originally intended and issue a new release sortly (pun intended). hahaha. 😎
Should be in a few hours, currently putting the final touches on some other new features. 👍
🌙 🌠 "Nothing good happens past 2am..."
from bogus.
Hi there @cmatskas ,
Thank you for your suggestion. I'm glad you like Bogus 😎. It should be pretty easy to extend Bogus to support ShortCodes. Also, I'd be happy to accept a PR for your feature so others benefit too.
I'm not fimilar with UK ShortCodes but 1) since this is locale specific to the UK and 2) I don't think you would need locale
JSON extension storage, you can simply implement your .ShortCode
as an extesion method off the Finance
data set.
Here is how to do that:
- Fork and checkout
Bogus
. - Run
build restore
in Command Prompt inside your fresh checkout before using Visual Studio. - Open Visual Studio and create a new file called
ExtensionsForUnitedKingdom.cs
insideBogus\Extensions
here:
ExtensionsForUnitedKingdom.cs:
namespace Bogus.Extensions.UnitedKingdom
{
public static class ExtensionsForUnitedKingdom
{
public static string ShortCode(this Bogus.DataSets.Finance finance)
{
//whatever is needed to create a valid shortcode.
}
}
}
- Write a unit test in
Bogus.Tests\DataSetTests\FinanceTest.cs
:
FinanceTest.cs:
[Fact]
public void can_generate_uk_shortcode()
{
finance.ShortCode().Should().Be("07-24-15");
}
- Compile with VS. Test with
build test
. - If all looks good,
build clean
and then commit your changes to your fork. - Finally, send in the PR. 😎
- We'll wait for CI to check the changes. Review the PR and publish.
Once your changes are published on NuGet, you'll add the new using
statement in your program:
using Bogus.Extensions.UnitedKingdom;
var faker = new Faker<BankAccount>()
.RuleFor( acc => acc.MyUKShortCode, f => f.Finance.ShortCode())
and all UK related extension methods light up over Bogus' API.
Please feel free to ping me at anytime if you need help with anything.
Hope that helps!
Brian
⌚ 🌆 "I just can't wait... I just can't wait... for saturday night..."
from bogus.
Hi @cmatskas ,
Good news, your feature request for UK banking Short Codes are now available in Bogus v19.
Simply import the Bogus.Extensions.UnitedKingdom
namespace as described here:
https://github.com/bchavez/Bogus#api-extension-methods
The .ShortCode()
extension method hangs off the Finance
data set, so f => f.Finance.ShortCode()
should just about do it.
Enjoy :)
Thanks,
Brian
🚶 😎 "So don't delay... act now supplies are running out..."
from bogus.
How come they're named ShortCodes here? The OP even says SortCode?
Great extension BTW, just a little confused as a consumer.
from bogus.
Hi @Nosmadas,
Thanks for your question. The official API is ShortCode()
defined here:
My reference to ShortCodes (with an s) in this thread is in the plural form (as a group) and references the ability to generate more than one ShortCode
with Bogus.
Is there something else in the United Kingdom that is also called "ShortCodes" that can cause confusion between ShortCode and ShortCodes?
Thanks,
Brian
💨 🚶 "Bubbles of gas in my brain... Send me off balance, it's not enough"
from bogus.
Hey @bchavez
The API looks great.
I was referring to this instead - https://en.wikipedia.org/wiki/Sort_code rather than plural vs singular.
Sort vs Short.
from bogus.
Related Issues (20)
- Add Extensions.Romanian HOT 2
- Update link to faker.js in Creating Locales Wiki page HOT 1
- The person full name locale is not set properly for zh_CN and zh_TW
- Bogus super slow HOT 1
- Invalid Zip Codes (US)
- Bogus is slow on Blazor WASM HOT 1
- Add Amka number (Greek social security number) to Extensions.Greece
- Option to filter out en_AU_ocker
- Generating a deep object graph based on rules HOT 1
- Xamarin fails to publish due to Nordic characters in Method names HOT 2
- Add Direct License Information In Nuget metadata HOT 2
- Foreign Key Constraint Violation Issue with Bogus and EF Core
- Binder throw ambiguous match exception for object with read only indexer property that has two implementations in base class HOT 2
- First and Full names are incorrectly generated with locale "sv" HOT 2
- Request to add language English (Hong Kong) / locale en_HK
- Faker.Tv() is missing from Bogus.Hollywood HOT 3
- Feature request: New localized data: Word(s).
- Add ability to except random numbers HOT 2
- Update Denmark (da) locale from faker-js
- Nuget for .NET 8.0.x HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bogus.